Question

SQL simple pour vous experts SQL.

J'ai deux champs (Accountno, Checkno). Il peut y avoir plus d'un contrôle qui a la même valeur. Il aura le même compte. Je voudrais une liste de Mytable affichant Accountno et Checkno, comme c'était le compte du nombre de fois qu'il existe.

Select Distinct AccountNo, CheckNo, Count(Distinct AccountNo, CheckNo) as Total
from MyTable
Était-ce utile?

La solution

Ce que vous recherchez est GROUP BY

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

Autres conseils

Select AccountNo, CheckNo, Count(*) as Total
from MyTable
group by AccountNo, CheckNo
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top