I have the following (example) data in a table
Value, Date, Device
I use the data to do simple SLA calculations, i.e. how many times during business hours was the data below a certain threshold.
Currently I run the following two queries like the following
select count(*), DATE(times) from SLA where device='some-dev' and DATE(times) between '2013-05-01' and '2013-05-31' and TIME(times) between '06:00:00' and '18:00:00' and value <150 group by DATE(times);
select count(*), DATE(times) from SLA where device='some-dev' and DATE(times) between '2013-05-01' and '2013-05-31' and TIME(times) between '06:00:00' and '18:00:00' group by DATE(times);
So two queries, one without a value < number and one with.
A few questions, is there a way to get these both into one query, so I could see a count of total data points and data points that were less than threshold value? Basically return three columns, one with count, one with count below thresh, and date
Beyond that, is there an easy way to tell mysql to ignore weekends when returning the data?
Thanks,
WHEREclause:DAYOFWEEK(times)<6. More about DAYOFWEEK function avalible here.