Home  >  Article  >  Database  >  05. 取SQL分组中的某几行数据

05. 取SQL分组中的某几行数据

WBOY
WBOYOriginal
2016-06-07 17:40:351192browse

对表中数据分组,有时只需要某列的聚合值;有时却需要返回整行数据,常用的方法有:子查询、ROW_NUMBER、APPLY,总体感觉还是ROW_NUMBER比较直观。 测试数据: ) testGroup testGroup(ID ,UserID int ,OrderID int ) GO insert testGroup ,,,,,,,, 4000

对表中数据分组,美国空间,有时只需要某列的聚合值;有时却需要返回整行数据,网站空间,常用的方法有:子查询、ROW_NUMBER、APPLY,虚拟主机,总体感觉还是ROW_NUMBER比较直观。
测试数据:

) testGroup testGroup ( ID , UserID int, OrderID int ) GO insert testGroup ,,,,,,,,4000

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn