Test FUNCTIONs
Now it's time to test the three functions you wrote in the previous exercise.
Diese Übung ist Teil des Kurses
<Kurs>Writing Functions and Stored Procedures in SQL Server</Kurs>Übungsanweisungen
- Display the first 100 records of
PickupDate,TripDistanceandFareAmountfromYellowTripData. - Determine the shift value of
PickupDateby passing the hour value todbo.GetShiftNumberfunction; display the shift and include it in theWHEREclause for shifts = 2 only. - Convert
TripDistanceto kilometers withdbo.ConvertMiletoKmfunction. - Convert
FareAmountto Euro (with exchange rate of 0.87) with thedbo.ConvertDollarfunction.
Interaktive praktische Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
SELECT
-- Select the first 100 records of PickupDate
TOP 100 ___,
-- Determine the shift value of PickupDate
dbo.___(___(___, ___)) AS 'Shift',
-- Select FareAmount
FareAmount,
-- Convert FareAmount to Euro
dbo.___(___, 0.87) AS 'FareinEuro',
-- Select TripDistance
TripDistance,
-- Convert TripDistance to kilometers
dbo.___(___) AS 'TripDistanceinKM'
FROM YellowTripData
-- Only include records for the 2nd shift
WHERE dbo.___(___(___, ___)) = 2;