문제

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
도움이 되었습니까?

해결책

What you are after is GROUP BY

Select AccountNo, CheckNo, Count(*) as Total
from MyTable
group by AccountNo, CheckNo

다른 팁

Select AccountNo, CheckNo, Count(*) as Total
from MyTable
group by AccountNo, CheckNo
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top