我有這兩個表,我必須寫這個SQL查詢(Microsoft Access中)之間:加入兩個一對多表
- 撰寫出了每個作者的銷量任何書籍有多少頭銜查詢(book_id)和多少個單位(訂購的數量),他們賣
我試圖與該查詢,但它不工作
SELECT authors.author_id, Count(orders.book_id) AS CountOfbook_id,
Sum(orders.quantity_ordered) AS SumOfquantity_ordered
FROM authors
LEFT JOIN orders ON authors.book_id = orders.book_id
GROUP BY authors.author_id;
,但它不工作,因爲它計算同一本書多次從customersOrders
那麼你試過了什麼?它產生了什麼結果/它與你想要的有什麼不同? –
請閱讀http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557和接受的答案 –
我寫了查詢我試過底部 – sparkle