I have a data table that has the following columns: id (string), date (date), alert (0 or 1).
Some sample data:
case001 2011-06-18 8:27:00 0
case002 2011-06-18 16:30:00 1
case003 2011-06-19 7:24:00 0
...
case150 2011-10-23 22:05:00 1
case151 2011-10-24 11:45:00 1
case152 2011-10-24 16:55:00 0
case153 2011-10-24 20:13:00 0
...
I want to be able to write a few SQL queries to compute the number of alerts per day (where 1 represents an alert, 0 represents no alert) and also the number of alerts per id per day.
Any ideas?
Thank you!!!
It depends on which DB you are using.
In Oracle you can use
truncfunction to truncate to a day (or month, etc)In MySQL you should use