Page 1 of 1

Not sure how to get it to sort and count

Posted: Mon Mar 03, 2003 6:45 pm
by ee99ee
Okay I've got a table that has 3 feilds: id, size, style. Right now, I have a SQL statement pulling the data from the database, and pushing it out to a webpage (using PHP of course). It just pulls everything from the table with that info, and sorts it by id. Here's an example:

Code: Select all

id    size   style
168   40S    TL
169   40S    OL
170   40S    ODB
171   40S    ODB
172   40S    ODB
173   40R    N
174   40R    N
Now, what I want it to do is that that information, and make a new table showing how much of each size and style are in the table. Example using above info:

Code: Select all

num   size   style
1 40S TL
1 40S OL
3 40S ODB
2 40R N

I'm not really sure how I should go about trying to get it to do that, so if you've got any suggestions on how, I'd love to hear them.

Thanks!!!

-ee99ee

Posted: Mon Mar 03, 2003 7:21 pm
by jason

Code: Select all

SELECT COUNT(id), size, style FROM table GROUP BY size
Or something like that.

btw, hi (newbienetwork from #php)

Posted: Mon Mar 03, 2003 7:41 pm
by ee99ee
woooo!!! thank you!!!!

btw, howdy! (eeiiee from #php of course)...


-ee99ee