scarhand Posted November 27, 2007 Share Posted November 27, 2007 lets say i have a table like this: name | age | sex mike | 22 | male mitch | 21 | male joan | 17 | female john | 33 | male and i want to select, count, and order all these results by sex (descending) without using any php variables to do so and after they are selected, i am going to be putting them in an html table that will look like this: sex | count male | 3 female | 1 i have no idea where to get started...i can do the php on my own but i dont have any clue what to use for the select statement...im sure it will have to include SELECT, COUNT, WHERE, and GROUP BY but honestly im not sure. any help would greatly be appreciated. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 select sex, count(sex) as t_count from tablename group by sex order by sex desc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.