Jump to content

One for the Mysql Masters!


scotchegg78

Recommended Posts

I have a working query which returns a count of all rows in a table per month....

 

select date_format(registrantDate, '%M'), count(*) from cr_registrant where registrantDate >= date_sub(now(),interval 12 month) group by date_format(registrantDate, '%M')

 

however within this total per month I would like it also broken up of into the various applicants per region.

The cr_registrant table has a filed which stores the officeID selected of the applicant. Of which the officeID in the cr_office table links the office to its region using cr_office.regionIDfk. of course cr_region has the regionID key and regionName key.

 

What I would like is to output the date so its columns are something like..

 

Month, Total Qty,(and then region totals that month..) South Region, North Region .. etc etc

 

Any ideas how or if this can be done in one qry, or shall i just do it in two?

Link to comment
Share on other sites

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.