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
Exercise instructions
- Use
CREATE OR ALTER
keywords to update theSumStationStats
function. - Change the parameter name to
@EndDate
and data type todate
. - Compare the
@EndDate
toEndDate
of theCapitalBikeShare
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;