I run a membership database that stores members' address info. I'd like to run an SQL query that pulls a count of members by their state, and orders them by state from highest to lowest, but it's beyond my grasp. (well, I could do a grunt solution that hits the db 50 times with 50 different SQL statements..ugh)
I think I need to use an array but I don't know how to run a query with an array. Any advice is appreciated!
select state, count(*) as cnt from members group by state order by cnt;
This will produce you a list like this:
CA | 1000 NV | 200 AZ | 100
I think you get the picture, as long as you have state separate then this is simple.