T-SQL:包含行计数作为唯一行的列
我有一个表,我们将调用 TableA 并包含以下 3 列数据,
Col1 Col2 Col3
a b c
a b c
d e f
g h i
g h i
g h i
我想返回一个如下所示的记录集:
Col1 Col2 Col3 Total
a b c 2
d e f 1
g h i 3
重复的行及其出现次数仅返回一次。不知道如何制定sql。感谢您的帮助!
I have a table, we'll call TableA and contains the following 3 columns with data
Col1 Col2 Col3
a b c
a b c
d e f
g h i
g h i
g h i
I want to return a record set that looks like this:
Col1 Col2 Col3 Total
a b c 2
d e f 1
g h i 3
Duplicate rows are only returned once along with the count of their occurrences. Not sure how to formulate the sql. Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
使用子查询。
use subquery .