Get startedGet started for free

CREATE OR ALTER

Change the SumStationStats function to enable SCHEMABINDING. Also change the parameter name to @EndDate and compare to EndDate of CapitalBikeShare table.

This exercise is part of the course

Writing Functions and Stored Procedures in SQL Server

View Course

Exercise instructions

  • Use CREATE OR ALTER keywords to update the SumStationStats function.
  • Change the parameter name to @EndDate and data type to date.
  • Compare the @EndDate to EndDate of the CapitalBikeShare table.
  • Enable SCHEMABINDING.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Update SumStationStats
___ ___ ___ FUNCTION dbo.___(___ AS ___)
-- Enable SCHEMABINDING
RETURNS TABLE ___ ___
AS
RETURN
SELECT
	StartStation,
    COUNT(ID) AS RideCount,
    SUM(DURATION) AS TotalDuration
FROM dbo.CapitalBikeShare
-- Cast EndDate as date and compare to @EndDate
WHERE CAST(___ AS Date) = ___
GROUP BY StartStation;
Edit and Run Code