Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

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 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

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

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

Source Link
lad2025
  • 156
  • 5

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

lang-sql

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