Monday, February 20, 2012

Is there an SQL command for this?

Okay I have a column

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