Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Last active February 18, 2022 10:40
Show Gist options
  • Save James-McNeill/66cb175fa5abf04790a9a3d24edd9e8d to your computer and use it in GitHub Desktop.
Save James-McNeill/66cb175fa5abf04790a9a3d24edd9e8d to your computer and use it in GitHub Desktop.
-- Declare your variables
DECLARE @start date
DECLARE @stop date
-- SET the relevant values for each variable
SET @start = '2021-06-01'
SET @stop = GETDATE()
-- Run select statement
SELECT t1.[DATETIME], COUNT(*) AS vol
FROM Medium.dbo.Earthquakes t1
WHERE t1.[DATETIME] BETWEEN @start AND DATEADD(MONTH, -3, @stop)
GROUP BY t1.[DATETIME]
ORDER BY t1.[DATETIME] DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment