求显示总行数
原表A:
ID NAME
1 张三
2 李四
4 王五
求解count代表无条件的总行数:
ID NAME count
1 张三 3
2 李四 3
不想采用语句:
Select *,(Select Count(*) Count From A where id<4) From A where id<4
还有其他方法吗?
[解决办法]
--> 测试数据:[test]if object_id('[test]') is not null drop table [test]create table [test]([ID] int,[NAME] varchar(4))insert [test]select 1,'张三' union allselect 2,'李四' union allselect 4,'王五'select * from(select *,COUNT(1)over(partition by 1) as [count] from test)twhere ID<4/*ID NAME count-----------------------1 张三 32 李四 3*/