select *,(select count(1) from article_tbl a where a.art_id >= a.art_id) as num from article_tbl a
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 3
10 test2 test2 NULL 2007-07-20 00:00:00.000 3
11 test3 test3 NULL 2007-07-23 00:00:00.000 3
我想要的结果是
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 1
10 test2 test2 NULL 2007-07-20 00:00:00.000 2
11 test3 test3 NULL 2007-07-23 00:00:00.000 3
当删除其中一条记录时,num也自动更新:
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 1
select *,(select count(1) from article_tbl a where a.art_id >= a.art_id) as num from article_tbl a
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 2
10 test2 test2 NULL 2007-07-20 00:00:00.000 2
11 test3 test3 NULL 2007-07-23 00:00:00.000 2
我想要的结果是
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 1
10 test2 test2 NULL 2007-07-20 00:00:00.000 2
11 test3 test3 NULL 2007-07-23 00:00:00.000 3
当删除其中一条记录时,num也自动更新:
art_id title desc times CreateDate num
2 test1 test1 NULL 2007-07-19 00:00:00.000 1