Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 17:40:35
Original
1287 people have browsed it

对表中数据分组,有时只需要某列的聚合值;有时却需要返回整行数据,常用的方法有:子查询、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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!