Dor Cohen
Dor Cohen

Reputation: 117

How to get the most displaying column value in SQL?

I have this table:

Aid id date
--------------
 1   1   19/12
 2   1   20/5
 3   2   30/2

I want to get the id that is showing the most so in this case I want to get 1 (SELECT id)...

Should be like this:

id
 1

I just want to get the max of count id

Upvotes: 0

Views: 39

Answers (2)

Dor Cohen
Dor Cohen

Reputation: 117

SELECT TOP 1 ArtistID
FROM AwardToArtis
group by ArtistID
order by ArtistID desc

thats solve it for me

Upvotes: 0

Ashish Gaur
Ashish Gaur

Reputation: 2050

SELECT TOP 1 id from 
(SELECT id, COUNT(id) AS freq FROM table1
GROUP BY id) t1
ORDER BY t1.freq desc

Here is the SQLFiddle

Upvotes: 3

Related Questions