2
我的數據庫表::如何編寫查詢來獲取月份的數據?
attendence date admission number attendence
2013-10-2 LSTM-0008/2013-2014 present
2013-10-19 LSTM-0008/2013-2014 absent
2013-9-20 LSTM-0008/2013-2014 present
上面一個是我的數據庫表。
,我想這樣的基於數據庫的表中顯示錶:
MonthName totalWorkingDays Present absent
october 26 1 1
november 26 1 0
我寫MySQL查詢像這樣:
SELECT DISTINCT monthname(attendencedate)as monthname , COUNT (*) as totalworking days,
(SELECT COUNT(*) FROM lstms_attendence WHERE attendence='present' AND addmissionno='LSTM-0008/2013-2014') as present,
(SELECT COUNT(*) FROM lstms_attendence WHERE attendence='absent' AND addmissionno='LSTM-0008/2013-2014') as absent
FROM lstms_attendence
WHERE addmissionno='LSTM-0008/2013-2014'
GROUP BY attendencedate;
它不是爲我工作的任何人給我建議。
Thanku它爲我工作。 –