Aan de slagGa gratis aan de slag

Calculating mode (II)

In the last exercise, you created a CTE which assigned row numbers to each unique value in OrderPrice. All you need to do now is to find the OrderPrice with the highest row number.

Deze oefening maakt deel uit van de cursus

Intermediate SQL Server

Cursus bekijken

Oefeninstructies

Use the CTE ModePrice to return the value of OrderPrice with the highest row number.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

-- CTE from the previous exercise
WITH ModePrice (OrderPrice, UnitPriceFrequency)
AS
(
	SELECT OrderPrice,
	ROW_NUMBER() 
    OVER (PARTITION BY OrderPrice ORDER BY OrderPrice) AS UnitPriceFrequency
	FROM Orders
)

-- Select the order price from the CTE
SELECT ___ AS ModeOrderPrice
FROM ___
-- Select the maximum UnitPriceFrequency from the CTE
WHERE UnitPriceFrequency IN (___ ___(___) FROM ___)
Code bewerken en uitvoeren