Subject: Count the same items
Posted By: stasnikov Post Date: 1/12/2007 8:16:54 AM
Hi,
does some one knows how to show the most used items items from a table??
like:

yellow
green
blue
yellow
yellow
green

the thing i have to see is the most used color. In this case it is yellow.

Please help me.


Reply By: mmcdonal Reply Date: 1/12/2007 11:23:45 AM
SELECT TOP 1 tblYourTableName.Color, Count(tblYourTableName.Color) AS CountOfColor
FROM tblYourTableName
GROUP BY tblYourTableName.Color;

In your case, this will return

Color      CountOfColor
yellow     3

HTH

mmcdonal
Reply By: stasnikov Reply Date: 1/15/2007 5:20:27 AM
Thanks it works!!!


Go to topic 54840

Return to index page 64
Return to index page 63
Return to index page 62
Return to index page 61
Return to index page 60
Return to index page 59
Return to index page 58
Return to index page 57
Return to index page 56
Return to index page 55