Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Vitaminwater

macrumors newbie
Original poster
Aug 18, 2009
21
0
Good afternoon everyone!

I was racking my brain today trying to figure out how I could possible figure out the number of occurrence's everything in my database has. I DO NOT want to search for an item and have it tell me how many times it happens in a database.

I want to query an entire column and count how many times it see's , 'XXXXX' and 'YYYYY'. And then output the top 5 most used number sets.

Can anyone shed any light on this? Maybe with arrays? I'm not sure...

Thanks Alot!
 
I did not test these queries, but I think you want something like:

select count(*) as qty, col_name from table_name group by col_name order by qty desc;

Or maybe something like:
select count(distinct col_name) from table_name;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.