March 31, 2013 at 3:22 am
Now working, thank you.
SELECT Coalesce( sGIG, 'Tot' ) as sGIG, Sum(Number) as Num
FROM (
SELECT LEFT (idDGIG, 2) AS sGIG, COUNT(idDGIG) AS NUMBER
FROM TABLE_LONG
WHERE
LEFT (idDGIG, 2) IN ('QM', 'QI', 'QO', 'QS')
AND DATE_START = DATE_ADD(CURDATE(), INTERVAL - 1 DAY)
GROUP BY sGIG
UNION ALL
SELECT LEFT (idDGIG, 2) AS sGIG, COUNT(idDGIG) AS NUMBER
FROM TABLE_SHORT
WHERE
LEFT (idDGIG, 2) IN ('QM', 'QI', 'QO', 'QS')
AND DATE_START = DATE_ADD(CURDATE(), INTERVAL - 1 DAY)
GROUP BY sGIG
) AS sums
Group by sGIG WITH ROLLUP;
+--------+--------+
| sGIG | NUMBER |
+--------+--------+
| QI | 11 |
| QM | 4 |
| QO | 22 |
| QS | 11 |
| Tot | 48 |
+--------+--------+
March 31, 2013 at 5:46 am
Great to hear you got it working. But please remember next time around you ask a question to please provide us with enough info to actually help you. So please read through Jeff's first link in his signature. We can't see what you see on your side, and without that info we're just taking a guess, probably wasting your time and ours as well. Anyhow, welcome to SSC!
March 31, 2013 at 12:50 pm
Jan Van der Eecken (3/31/2013)
Great to hear you got it working. But please remember next time around you ask a question to please provide us with enough info to actually help you. So please read through Jeff's first link in his signature. We can't see what you see on your side, and without that info we're just taking a guess, probably wasting your time and ours as well. Anyhow, welcome to SSC!
Of course !
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply