使用 SQL 获取不同计数?
为您的 SQL 专家提供简单的 SQL。
我有两个字段(AccountNo、CheckNo)。可以有超过 1 个具有相同值的 checkno。它将具有相同的 AccountNo。我想要 mytable 中的一个列表,显示 AccountNo 和 CheckNo,以及它存在的次数。
Select Distinct AccountNo, CheckNo, Count(Distinct AccountNo, CheckNo) as Total
from MyTable
Simple SQL for you SQL experts.
I have two fields (AccountNo, CheckNo). There can be more than 1 checkno that has the same value. It will have the same AccountNo. I would like a listing from mytable displaying AccountNo and CheckNo, as was as the count of how many times it exists.
Select Distinct AccountNo, CheckNo, Count(Distinct AccountNo, CheckNo) as Total
from MyTable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你所追求的是
GROUP BY
What you are after is
GROUP BY