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
https://forums.phpfreaks.com/topic/111468-one-for-the-mysql-masters/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.