LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Writing Functions and Stored Procedures in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

-- 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;
Code bearbeiten und ausführen