Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the database: Write SQL queries for each of the questions below. A) Find a

ID: 3872570 • Letter: U

Question

Using the database: Write SQL queries for each of the questions below.

A) Find all the customers who have invoice total greater than 5.65. Print the first and last name, postal code, and invoice total for such customers. Number of rows returned in the result = 179

B) Find all the Employees to whom no other employee reports to. Print the Id, and the first and last name of such employees. Number of rows returned in the result = 5

TEE Track Trackld T Album Artist Artistld Name MediaType MediaTypeld Name Tite Artistld Albumld MediaTypeld Genreld Composer Milliseconds Genre Genreld Name Playlist Playlistd Name PlaylistTrack Playlistic Trackld Bytes UnitPrice Employee Employeeld LastName FirstName InvoiceLine InvoiceLineld Invoiceld Trackld UnitPrice Quantity Customer Customerld FirstName LastName Company Address ReportsTo BirthDate HireDate Address City State Country PostalCode Phone Fax Email Invoice Invoiceld Customerld InvoiceDate illingAddress BillingCity BillingState BillingCountry State Country PostalCode Fax SupportRepld Total

Explanation / Answer

Hi, Please find the queries below. I couldn't verify the number of rows returned as I didn't have access to your database. If you want to limit the number of rows being returned, kindly add "limit 5" or "limit 179" in the end before semicolon.

Let me know if you have any doubts in understanding any of these queries.

1) Select Playlist.PlaylistId, Playlist.Name from Playlist where PlaylistId in ( select PlaylistId from PlaylistTrack, Track where PlaylistTrack.TrackId=Track.TrackId group by PlaylistId having count(DISTINCT Composer)>=50) ;

A) select FirstName,LastName, PostalCode, sum(total) from Customer, Invoice where Customer.CustomerId=Invoice.CustomerId group by Invoice.CustomerId having sum(total)>5.65;

B) Select EmployeeId,FirstName,LastName from Employee where EmployeeId not in(Select ReportsTo from Employee);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote