Skip to content

SQL query to group by datetime and get total values for 2 other fields

I have a problem writing the sql query that will group a datetime column (Modified) into days, and for each day give me the count of a value of another field, Status which can be either 1 or 2.

I have tried with just getting the count of status=1, but even this doesn’t give my what I want:

Below are some sample data and the results I want.

Expected results:

Advertisement

Answer

This should give you what you are after:

User contributions licensed under: CC BY-SA
10 People found this is helpful