Red
Red
Blue
Yellow
Blue
Blue
Blue
Blue
I want to return the value that appears most i.e. in this case Blue.
Thanks
BenThere is probably a more efficient way...
SELECT TOP 1 X, Count(*)
FROM table
GROUP BY X
ORDER BY Count(*) DESC
Red
Red
Blue
Yellow
Blue
Blue
Blue
Blue
I want to return the value that appears most i.e. in this case Blue.
Thanks
BenThere is probably a more efficient way...
SELECT TOP 1 X, Count(*)
FROM table
GROUP BY X
ORDER BY Count(*) DESC
No comments:
Post a Comment