SQL coursera Module 3 Coding Assignment

在这里插入图片描述
Module 3
1./Using a subquery, find the names of all the tracks for the album “Californication”./

SELECT Name
FROM Tracks
WHERE AlbumId IN (SELECT AlbumId
FROM Albums WHERE Title = “Californication”)

2./Find the total number of invoices for each customer along with the customer’s full name, city and email/

SELECT SUM(i.InvoiceID) AS totalnumber, c.FirstName, c.LastName, c.Email
From Invoices i INNER JOIN Customers c
ON i.CustomerID = c.CustomerID
GROUP BY c.CustomerID

3./Retrieve the track name, album, artistID, and trackID for all the albums./

SELECT t.Name, t.TrackId, a.Title, a.ArtistId
From Albums a LEFT JOIN Tracks t
ON a.AlbumId = t.AlbumId

/Retrieve a list with the managers last name, and the last name of the employees who report to him or her/
SELECT M.LastName AS Manager,
E.LastName AS Employee
FROM Employees E, Employees M
WHERE E.ReportsTo = M.EmployeeID

5./Find the name and ID of the artists who do not have albums./

SELECT Name,
a.ArtistId,
b.Title
FROM Artists a
LEFT JOIN Albums b
ON a.ArtistId = b.ArtistId
WHERE b.Title IS NULL

/Use a UNION to create a list of all the employee’s and customer’s first names and last names ordered by the last name in descending order./
SELECT FirstName, LastName
FROM Employees
UNION
SELECT FirstName, LastName
FROM Customers
ORDER BY LastName DESC

http://web.vietxam.com/sql/sqlite/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值