Skip to main content
Code Review

Return to Revisions

2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/

I am getting the output but I am not sure if this is correct. I saw one or two solution using joins So I am confused that whether the query I have written is correct or not

It is a good practice to use JOIN : Explicit vs implicit SQL joins.

Second you could use aliases so you do not have to type entire table name.

SELECT SUM(po.quantity) AS TotalQuantity
 ,SUM(po.quantity*p.price) AS TotalSaleAmount 
FROM productorder po
JOIN product p
 ON po.ProductId = p.ProductId 
JOIN `order` o
 ON o.OrderId = po.OrderId 
WHERE o.OrderDate = CURDATE();

SqlFiddleDemo

lad2025
  • 156
  • 5
default

AltStyle によって変換されたページ (->オリジナル) /