Forum Discussion
EHaft
1 year agoNew Member
SQL triple joins, or how to distinctly combine order details
Hi there, I'm having some trouble attempting to return the total price for each order placed. I'm working with the following tables: Orders (OrderID, OrderDate, Location) Sales (Order...
- Anonymous1 year ago
Hi EHaft ,
You may try:
SELECT Orders.OrderID, SUM(Sales.QuantitySold*Products.SellPrice) AS 'Total Price' FROM Sales LEFT JOIN Orders ON Orders.OrderID = Sales.OrderID LEFT JOIN Products ON Products.ProductName = Sales.ProductSold GROUP BY Orders.OrderIDIf this statement doesn't work on your end, could you please provide us with the table creation statement and sample data, as well as your expect result?
Note:Please be careful not to include sensitive information)
Best regards.
Community Support Team_Caitlyn
Anonymous
1 year agoNot applicable
Hi EHaft ,
You may try:
SELECT
Orders.OrderID, SUM(Sales.QuantitySold*Products.SellPrice) AS 'Total Price'
FROM Sales
LEFT JOIN Orders ON Orders.OrderID = Sales.OrderID
LEFT JOIN Products ON Products.ProductName = Sales.ProductSold
GROUP BY Orders.OrderID
If this statement doesn't work on your end, could you please provide us with the table creation statement and sample data, as well as your expect result?
Note:Please be careful not to include sensitive information)
Best regards.
Community Support Team_Caitlyn