Use EDA to find impossible scenarios
Calculate how many YellowTripData
records have each type of error discovered during EDA.
This exercise is part of the course
Writing Functions and Stored Procedures in SQL Server
Exercise instructions
- Use
CASE
andCOUNT
to understand how many records contain the following errors: DropOffDate
beforePickupDate
,DropOffDate
before today,PickupDate
before today,TripDistance
is zero.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
-- PickupDate is after today
COUNT (CASE WHEN ___ > ___() THEN 1 END) AS 'FuturePickup',
-- DropOffDate is after today
COUNT (CASE WHEN ___ > ___() THEN 1 END) AS 'FutureDropOff',
-- PickupDate is after DropOffDate
COUNT (CASE WHEN ___ > ___ THEN 1 END) AS 'PickupBeforeDropoff',
-- TripDistance is 0
COUNT (CASE WHEN ___ = ___ THEN 1 END) AS 'ZeroTripDistance'
FROM YellowTripData;