CREATE OR ALTER
Change the SumStationStats function to enable SCHEMABINDING. Also change the parameter name to @EndDate and compare to EndDate of CapitalBikeShare table.
Cet exercice fait partie du cours
Writing Functions and Stored Procedures in SQL Server
Instructions
- Use
CREATE OR ALTERkeywords to update theSumStationStatsfunction. - Change the parameter name to
@EndDateand data type todate. - Compare the
@EndDatetoEndDateof theCapitalBikeSharetable. - Enable
SCHEMABINDING.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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;