Good morning, mysql query which displays cases that have a date field completed & a total row amount, I want calculate this against the total cases but unsure if I can do all this inside one query. For example the current query outputs
Aug Sep Nov Total
10 20 20 50
The code for that being
SELECT * from(
Select Count(b.CaseID) As TotDB
from tblcontacts a
Inner Join tblcases b
On a.ContactID = b.ContactAssignedTo)a
CROSS JOIN
(Select
Sum(Month(b.StatusSubmittedDate) = 8) As Aug,
Sum(Month(b.StatusSubmittedDate) = 9) As Sep,
Sum(Month(b.StatusSubmittedDate) = 10) As Oct,
Count(b.CaseID) As Total,
ROUND (100*Count(b.CaseID)/Count(b.CaseID),2) As Conversion
From
tblcontacts a Inner Join
tblcases b On a.ContactID = b.ContactAssignedTo
Where
b.StatusSubmittedDate > '2012 - 01 - 01'
Group By
a.ContactFullName With Rollup
Having
Sum(b.CaseCommission) > 0.01)b
What I need to it output is the below so I added the TotDB line above to see if that would help, it didn’t. What I need to find out is can I have a column in this query that bypasses the where/having clause to display all records
Aug Sep Nov Tot TotDB %Converted
10 20 20 50 100 50%
Thanks
probably you should do like this: