Jump to content

Generating report chart, with count by day of week.


Recommended Posts

I am at work and keep getting interupted by less important things, like the real world so please for give me if this isn't the clearest post.

 

I am trying to generate report that looks like this:

 

EngineMonTueWedThuFriTotal

Product 1102036

Product 2001124

Repaired1031510

 

 

I have the select of each product that was repaired that week right, I just can't figure out how to get the count for each engine per day and in the cell.

 

Here are the two SQL queries:

To get the row data:

Select
  				engines.Brand,
  				engines.Scale,
  				engines.Description,
  				repairs.raitem.repairDate,
  				COUNT(*) As repairedEngines
		From
  				repairs.raitem Inner Join
  				engines On repairs.raitem.description = engines.engineId
		Where
  				Week(repairs.raitem.repairDate) = Week(Current_Date())
		Group By
  				bli.engines.Brand, bli.engines.Description

 

and

 

To tally the days (I know I can do this with variables in php, but I am using this until I get the cell data.

Select
  					repairs.raitem.repairDate,
  					COUNT(*) as repaired
			From
  					repairs.raitem
			Where
  					YEARweek(repairs.raitem.repairDate) = YEARweek(Now())
			Group By
  					repairs.raitem.repairDate
  				Order By
  					repairs.raitem.repairDate

 

 

Here are the tables:

 

repairs.ra (Return Authorization for repair)

id, customer, etc..

 

repairs.raitem (each returned item on the ra)

id, raID(FK to ra), repairDate, etc.

 

bli.engines (company's product list)

id, description (etc)

  • 3 weeks later...

When I group by DAYOFWEEK() it only returns !NULL results.

 

If There were no results for tuesday, the chart would say

 

MON TUE WED THUR FRI SAT SUN
1    4   2   3   6    3

 

I guess Im going to have to code a little bit huh...

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.