Jump to content

selecting, counting, and ordering similar data that exists


Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.