六、資料庫內有三個表格,分別是 Product、Sales_table、Supplier。這三個表
的欄位名稱與資料紀錄如下:
Product Table
ID name SupplyID
P001 玄天花 S001
P002 仙草 S003
P003 吉梗 S002
P006 辣椒 S001
P007 富士蘋果 S003
P008 岡山羊 S002
P009 台南牛肉 S003
Sales_table
Seq ProdID amount
ord001 P001 12000
ord002 P009 20000
ord003 P007 16000
ord004 P006 25500
ord005 P002 5000
ord006 P001 17000
Supplier Table
ID name
S001 大發
S002 大紫
S003 大展
S004 大途
請回答下列問題:
【題組】(三)請寫出以下的 SQL 陳述句的結果集。(10 分)
SELECT Supplier.ID as SuplID, Supplier.name as SuplName, (SELECT
SUM (Sales_table.amount) FROM Sales_table WHERE Sales_table.ProdID
IN (SELECT Product.ID FROM Product WHERE Product.SupplyID =
Supplier.ID))AS total_amount FROM Supplier;