Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions