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.
Cet exercice fait partie du cours
Writing Functions and Stored Procedures in SQL Server
Instructions
- Create a function named
dbo.GetTripDistanceHotDeck()that returns anumericdata type. - Select the first
TripDistancevalue fromYellowTripDatasample of1000records. - The sample of
1000records should only include those whereTripDistanceis more than zero.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
-- 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;