Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* a. Find distinct track names that start with “Z”.Sort the output alphabetically.*/
- /*select distinct track.Name
- from Track where Name like 'Z%' order by Name;*/
- /* b. Find the first names of the employees who are older than their supervisor.
- Hint: ReportsTo attribute in Employee table stores the EmployeeId of the supervisor. Sort the output alphabetically*/
- /*select FirstName from Employee as E1
- where BirthDate >
- (select BirthDate from Employee where EmployeeId = E1.ReportsTo)
- order by FirstName;*/
- /* c. Find the name of the highest priced track. If more than one track has the highest
- price, return the names of all such tracks. Sort the output alphabetically based on the track name*/
- /*select Track.name from Track
- where UnitPrice >=
- (select max(e.UnitPrice) from Track as e)
- order by Name;*/
- /* d. Find a list containing the total amount spend by a customer. Include the customer’s id and
- the last names along with the total amount. For customers who did not make any purchase, make sure to include
- them as well (the total should be 0.00 for those customers).BUG HERE DOESNT WORK HOW SUPPOSED TO PROBS*/
- /*select CustomerId, LastName, Total as Total_Spent
- from Customer Natural right outer join Invoice;*/
- /* e. Find the title of the highest priced album CHECK IF WORKS*/
- /*select Title from Album natural join Track
- group by AlbumId having sum(UnitPrice) >= all
- (select sum(UnitPrice) from Track group by AlbumId);*/
- /* f. Finda distinct list containing the titles of albums that are never sold. Consider
- an album never sold if none of its tracks are sold. Sort the output alphabetically.*/
- /*select distinct Title
- from Album natural join Track natural join invoiceline
- group by AlbumId
- having sum(Quantity) = 0
- order by Title;*/
- /* g. Create a view that returns customers’ first and last names along with
- corresponding sums of all their invoice totals. Name the view as “CustomerInvoices.” */
- /*create view CustomerInvoices as
- select FirstName, LastName, sum(Total) as InvoiceTotal
- from Customer natural join invoice
- group by CustomerId;
- select* from CustomerInvoices;*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement