Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please don't be stubborn and I entered the code you gave me once, but there's no data at all. I want the perfect code for

Please don't be stubborn and I entered the code you gave me once, but there's no data at all. I want the perfect code for the question, and please refer to the picture in the data table I attached, and the code I entered at the bottom of the question doesn't show any data at all. So I want a different code. And never make a new data table and use the table pictures in the pictures I attached. Please don't write the same code as this because the code I wrote down is wrong. Please give me another code that fits the question.

Question

single SQL statement unless otherwise specified (you can use UNION/INTERSECT/EXCEPT and the WITH clause if needed). Provide your answers and screenshots of the results in the required areas. Your SQL statements should have the correct logic and display the correct results as well.

Q1- Find the course(s) taken by the fewest students in the year 2006. The result should display the course title and the number of students. If a student has taken the same course more than once, this student should be counted only once.

Wrong code

with course_enrollment as

(

select course_id, count(distinct student_id) as number_students

from takes

where year = 2006

group by course_id

)

select title, number_students

from course_enrollment as ce join course as c on ce.course_id = c.course_id

order by number_students;

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage 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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

Explain the key areas in which service employees need training.

Answered: 1 week ago

Question

Understand the role of internal marketing and communications.

Answered: 1 week ago