私はpgadminIII(postgreSQL)を使用しています
次のテーブルがあります:Book、Publisher、OrderLine、ShopOrder。
次のSQLを使用します。
SELECT
Book.BookID AS "Book ID"
,Book.Title AS "Book title"
,SUM(OrderLine.quantity) AS "Number Ordered"
,ShopOrder.OrderDate AS "Order Date"
FROM (((Book
INNER JOIN OrderLine
ON Book.BookID = OrderLine.BookID)
INNER JOIN Publisher
ON Book.PublisherID = Publisher.PublisherID )
INNER JOIN ShopOrder
ON OrderLine.ShopOrderID = ShopOrder.ShopOrderID)
GROUP BY ShopOrder.OrderDate, Name, Book.BookID
.
これを(WHERE Publisher.Name = "Smith Smitheson"
)
私はそれをどこに置くべきかわかりません、または私がそれを正しくやっているなら、何か助けをお願いしますか?
...
INNER JOIN Publisher ON Book.PublisherID = Publisher.PublisherID AND Publisher.Name = 'Smith Smitheson' )
...
または
SELECT Book.BookID AS "Book ID" ,Book.Title AS "Book title"
,SUM(OrderLine.quantity) AS "Number Ordered" ,ShopOrder.OrderDate AS
"Order Date" FROM Book
INNER JOIN OrderLine ON Book.BookID = OrderLine.BookID
INNER JOIN Publisher ON Book.PublisherID = Publisher.PublisherID
INNER JOIN ShopOrder ON OrderLine.ShopOrderID = ShopOrder.ShopOrderID
WHERE Publisher.Name = 'Smith Smitheson'
GROUP BY ShopOrder.OrderDate, Name, Book.BookID