ComenzarEmpieza gratis

Hot Deck imputation

Create a function named dbo.GetTripDistanceHotDeck that returns a TripDistance value via Hot Deck methodology. TripDistance should have a precision of 18 and 4 decimal places.

Este ejercicio forma parte del curso

Writing Functions and Stored Procedures in SQL Server

Ver curso

Instrucciones del ejercicio

  • Create a function named dbo.GetTripDistanceHotDeck() that returns a numeric data type.
  • Select the first TripDistance value from YellowTripData sample of 1000 records.
  • The sample of 1000 records should only include those where TripDistance is more than zero.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

-- Create the function
___ ___ ___.___()
-- Specify return data type
___ ___(18,4)
AS 
BEGIN
RETURN
	-- Select the first TripDistance value
	(___ TOP 1 ___
	FROM YellowTripData
    -- Sample 1000 records
	TABLESAMPLE(1000 rows)
    -- Only include records where TripDistance is > 0
	___ ___ ___ ___)
END;
Editar y ejecutar código