Home > database > Consult a matter of database queries
Consult a matter of database queries
Time:03-31
Everyone a great god, and in a small staff, want to ask a small problem, below this table, I'd like to list each device according to the occurrence date, number of each failure type of failure, The original data is as follows:
Want to query results are as follows:
CodePudding user response:
Select id, description, count (1) the number of times the from date table where happen between "start time" and "end time" group by id, description
CodePudding user response:
SELECT device id, fault description, COUNT (1) FROM the table WHERE the CONVERT (DATE, CONVERT (VARCHAR (10), DATE)) BETWEEN start DATE AND end DATE GROUP BY device id, fault description
CodePudding user response:
I'm sorry I'm sorry, I describe the wrong, is to want to get into this appearance,