-2
我必須檢索每個顧客的名字以及他們訂購了多少比薩餅。如果沒有訂購比薩餅,則爲NULL。如何檢索每個顧客的名字以及他們訂購了多少比薩餅?
SELECT blank 1
FROM blank 2(
SELECT blank 3 AS quantity
FROM ORDERS NATURAL JOIN ORDERCONTENTS
GROUP BY blank 4) as quantity
ON customers.customerID=quantity.customerID
ORDER BY name;
該數據庫包含在這個佈局5個表:
Customers
columns
customerID,
name,
address,
phoneNumber,
email
Ordercontents
columns
orderID,
name,
quantity
orders
columns
orderID,
customerID,
postcode,
Date
products
columns
name,
price
stores
columns
postcode,
address,
phoneNumber
編號的空白必須更換產生的結果。
請參閱https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple- sql-query – Strawberry