I am working with pgadminIII (postgreSQL)
I have the following tables: Book, Publisher, OrderLine, ShopOrder.
With the following 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
.
I would like to use this with a (WHERE Publisher.Name = "Smith Smitheson"
)
I dont know where to put it, or if im doing it right, any help please?
...
INNER JOIN Publisher ON Book.PublisherID = Publisher.PublisherID AND Publisher.Name = 'Smith Smitheson' )
...
or
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With