Hi everyone! I have a question:
How to select the orderID, order date and the maximum-price product of each order in the
below tables in 2 ways:
1-using correlated sub-query
2-not using correlated sub-query
I only selected orderID, order date and the maximum price of each order but not including
the unit name because it is on the other table and I cannot group it.
This is my query:
SELECT dbo.[Order Details].OrderID, Max(dbo.[Order Details].UnitPrice)as MaxUnitprice, dbo.Orders.OrderDate FROM dbo.[Order Details] INNER JOIN dbo.Products ON dbo.[Order Details].ProductID = dbo.Products.ProductID INNER JOIN dbo.Orders ON dbo.[Order Details].OrderID = dbo.Orders.OrderID GROUP BY dbo.[Order Details].OrderID, dbo.Orders.OrderDate
This is the database: