try following to see the problem: select count(surname) as CNT, birthNumber from customer group by birthNumber order by CNT desc