摘要: 阅读全文
posted @ 2013-11-05 11:51 xust 阅读(109) 评论(0) 推荐(0)
摘要: 对表中数据分组,有时只需要某列的聚合值;有时却需要返回整行数据,常用的方法有:子查询、ROW_NUMBER、APPLY,总体感觉还是ROW_NUMBER比较直观。测试数据:if OBJECT_ID('testGroup') is not nulldrop table testGroupGOcreate table testGroup(ID int identity primary key,UserID int,OrderID int) GOinsert testGroup select 1,10 union allselect 1,20 union allselect 1,30 阅读全文
posted @ 2013-11-05 11:43 xust 阅读(258) 评论(0) 推荐(0)