Forum Discussion

EHaft's avatar
EHaft
New Member
1 year ago
Solved

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...
  • Anonymous's avatar
    Anonymous
    1 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.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