CREATE OR ALTER
Altere a função SumStationStats para habilitar SCHEMABINDING. Também mude o nome do parâmetro para @EndDate e compare com a coluna EndDate da tabela CapitalBikeShare.
Este exercicio faz parte do curso
Escrevendo Funções e Procedures no SQL Server
Instruções do exercicio
- Use as palavras-chave
CREATE OR ALTERpara atualizar a funçãoSumStationStats. - Altere o nome do parâmetro para
@EndDatee o tipo de dado paradate. - Compare
@EndDatecomEndDateda tabelaCapitalBikeShare. - Habilite
SCHEMABINDING.
exercicio interativo prático
Tente este exercicio completando este código de exemplo.
-- 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;