Hi everyone, I need your help.
I try this query in MySQL:
SELECT
COALESCE(`Zn`,'Tot') `Zn`
, COALESCE(`description zn`,'Tot') `description zn`
, `tot inf`
, `tot hh o`
, `tot hh i`
, `tot hh L`
, ((`tot inf`/`tot hh L`)*1000)*0.9213 `Freq`
FROM (SELECT
A.zn
, B.znDescr 'description zn'
, COUNT(*) 'tot inf'
, hhL 'tot hh o'
, hhLI 'tot hh i'
, (hhL+hhLI) 'tot hh L'
, 'Freq'
FROM tbl_A A
JOIN tbl_B B ON A.zn=B.zn
WHERE 1
AND YEAR(`mySQLDate`) = '2011'
AND description<>'it'
GROUP BY A.zn
WITH ROLLUP
) x;
And this is the output in MySQL:
Zn description zn tot inf tot hh o tot hh i tot hh L Freq
4P Sa 2 12869 8953 21822 0,08443772
6M Ca 3 18105 15270 33375 0,08281348
6P Ta 1 14131 12154 26285 0,03504994
Tot Ta 6 14131 12154 26285 0.21030239
- Why in the last row of the output in the
description zn
I haveTa
and notTot
? - Why for the columns
tot inf
,tot hh o
,tot hh i
,tot hh L
andFreq
I don’t have the finally sum ?
I need this output:
Zn description zn tot inf tot hh o tot hh i tot hh L Freq
4P Sa 2 12869 8953 21822 0,08443772
6M Ca 3 18105 15270 33375 0,08281348
6P Ta 1 14131 12154 26285 0,03504994
--- --- 6 45132 36337 81482 0,23735154
Can you help me?
Many thanks, cheers.