Count devices per day in a given date range
I have a table which has devices with 3 statuses, Pass, Fail and Warning.
Table Columns: overall_status
, DateTime
, DeviceName
I want to generate a trend graph of count of devices based on the daily status. The count is on all the devices for each day. The table above will have device data repeated for multiple dates.
Example: I want to generate a stacked bar graph, which will show count of devices which are pass, fail or warning. Need to get a query which I can use to get the response back with DateTime
, count of failed devices, count of devices passed, count of devices having warning over a range of dates.
select * (select count(*) from status_table where overall_status = 'Fail' and startDate > "" and endDate < "") as failedCount,
(select count(*) from status_table where overall_status = 'Warning' and startDate > "" and endDate < "") as WarningCount,
(select count(*) from status_table where overall_status = 'Pass' startDate > "" and endDate < "") as passCount from status_table
Is there a better solution?
from Recent Questions - Stack Overflow https://ift.tt/3ow7MRG
https://ift.tt/eA8V8J
Comments
Post a Comment