Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

counting total recs for each state?

Codes here !

Moderators: macek, egami, gesf

counting total recs for each state?

Postby cgchris99 » Sat Jul 12, 2003 1:10 pm

I have a bunch of event records for various event dates.

I want to write an select state that shows the following

State Count
AZ 50
AR 2
AK 450
CO 75
CT 92

etc.

sorted by state of course.

How do I do this.

thanks for any help
cgchris99
New php-forum User
New php-forum User
 
Posts: 19
Joined: Sun Apr 13, 2003 7:23 pm

Re: counting total recs for each state?

Postby swirlee » Sat Jul 12, 2003 1:49 pm

Try this:

Code: Select all
SELECT State, COUNT(*) AS Count FROM tbl_name GROUP BY State ORDER BY State;


Answered pretty much the exact same question yesterday -- you might try a search of the board before posting next time.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.