-1

I tried to find total amount for REPORT_STATUS IN REPORT table but I dont know how. I just can count of REPORT_STATUS but not by month.

$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);
hakre
  • 193,403
  • 52
  • 435
  • 836
  • Have a look at this perhaps http://stackoverflow.com/questions/5040141/how-to-write-an-sql-query-that-counts-the-number-of-rows-per-month-and-year – AshHimself Dec 21 '11 at 07:49

1 Answers1

0

GROUP BY is your friend. Something like this:

SELECT month, COUNT(REPORT_STATUS) FROM REPORT WHERE REPORT_STATUS = 1 GROUP BY month
PiTheNumber
  • 22,828
  • 17
  • 107
  • 180
  • What is it you still can't do? What do you get as result? What do you want? Is there an error? ... Please work on your question. – PiTheNumber Dec 21 '11 at 08:51