我试图查找REPORT_STATUS
IN REPORT表的总金额,但我不知道如何。我只能计算REPORT_STATUS
而不是按月计算。
$count = "SELECT
(SELECT COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 1 ) as
NumberOfReport1, (SELECT COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 2)
as NumberOfAReport2,(SELECT COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 3)
as NumberOfReport3,(SELECT COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 4)
as NumberOfReport4 ";
$result1= mysql_query($count);
答案 0 :(得分:0)
GROUP BY是你的朋友。像这样:
SELECT month, COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 1 GROUP BY month