IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Intermediate SQL Server

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

-- 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 ___)
Modifica ed esegui il codice