Quick report does not see fields nuSQL
Posted: Wed Aug 04, 2021 8:49 am
In a subquery, the monthly daily summary
The date field contains the start time of the shift - 8:00 and 20:00
It is necessary to calculate the amounts by fields and the amount of shifts.
Everything works correctly in phpmyadmin.
What could be the reason for this behavior?
Doesn't see the field through the temporary table either
The date field contains the start time of the shift - 8:00 and 20:00
It is necessary to calculate the amounts by fields and the amount of shifts.
Everything works correctly in phpmyadmin.
What could be the reason for this behavior?
Code: Select all
SELECT DATE_FORMAT(h.adat,'%m') AS mes, h.fio, SUM(h.kol) as kol, SUM(h.gm) AS gm, SUM(h.ton) AS tn, SUM(h.km) AS km, SUM(h.den) AS den, SUM(h.night) AS night, h.mast
FROM
(SELECT DATE_FORMAT(tabel.tab_data,'%d.%m.%Y') AS adat,
vodit.vod_fio AS fio,
IF(TIME_FORMAT(tabel.tab_data,'%H')='08','1','') AS den,
IF(TIME_FORMAT(tabel.tab_data,'%H')='20','1','') AS night,
SUM(hodki.hod_kol) AS kol,
SUM(hodki.hod_gm) AS gm,
SUM(hodki.hod_ton) AS ton,
SUM(hodki.hod_km) AS km,
master.mas_fio AS mast
FROM
hodki
JOIN vodit ON hodki.hod_vod = vodit.vodit_id
JOIN tabel ON hodki.hod_tab = tabel.tabel_id
JOIN master ON tabel.tab_mast = master.master_id
WHERE DATE_FORMAT(tabel.tab_data,'%Y %m') = DATE_FORMAT('#rep_mes#','%Y %m')
-- WHERE DATE_FORMAT(tabel.tab_data,'%Y.%m') ='2021.06'
GROUP BY fio,1
ORDER BY fio ) AS h
GROUP BY fio, mast
ORDER BY 2,3