Question: This question is for SQL . The below SQL code generates a report of all the car models put in the assigned states within the

This question is for SQL.
The below SQL code generates a report of all the car models put in the assigned states within the last day.
Could you please help modify the below SQL code to also include the names of the models tied to each state?
SELECT
'UNSCHEDULED_MAINT' AS STATE, COUNT(*) AS Models_Count
FROM
Models List
WHERE
state in 'UNSCHEDULED_MAINT'
AND down_date CURRENT_DATE - INTERVAL '1' day
UNION ALL
SELECT
'SCHEDULED_MAINT' AS STATE, COUNT(*) AS Models_Count
FROM
Models List
WHERE
state in 'SCHEDULED_MAINT'
AND down_date CURRENT_DATE - INTERVAL '1' day
UNION ALL
SELECT
'Running' AS state,
COUNT(*) AS Models_count
FROM
Models List
WHERE
state = 'Running'
AND down_date CURRENT_DATE - INTERVAL '1' day;
 This question is for SQL. The below SQL code generates a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!