获取以前记录的总数 [英] Get the total number of previous records

查看:116
本文介绍了获取以前记录的总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MS Access 中创建一个查询,需要使用以前记录的总数更新新创建的字段。这样的事情:



原始表格:

I am creating a query in MS Access that needs to update newly created field with the total number of previous records. Something like this:

Original table:

|  ID | Name |
--------------
|  1  | Mark |
--------------
|  2  | Mich |
--------------
|  3  | Isak |
--------------





现在我添加另一列(类型为int),例如Ordinal_Number:





Now I add another column ( of type int ), e.g. Ordinal_Number :

|  ID | Name | Ordinal_Number |
-------------------------------
|  1  | Mark |                |
-------------------------------
|  2  | Mich |                | 
-------------------------------
|  3  | Isak |                | 
-------------------------------





现在我需要填写Ordinal_Number以前的记录数:





Now I need to fill Ordinal_Number with the number of previous records :

|  ID | Name | Ordinal_Number |
-------------------------------
|  1  | Mark |       0        |
-------------------------------
|  2  | Mich |       1        | 
-------------------------------
|  3  | Isac |       2        | 
-------------------------------





我甚至无法理解如何尝试解决这个问题所以我在这里问。



I couldn't even get the idea how to try fighting this problem so I am asking here.

推荐答案

当您在表中插入数据时,在插入查找最大ID数之前,您可以传递该ID值 - 1,要保存在表格中的名称
When you are inserting data in table, before inserting find maximum number of ID and then you can pass that ID value - 1, with name to save in table


这篇关于获取以前记录的总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆