Start with the basic count of intakes between two dates, grouped by zip code:
SELECT
zip,
COUNT(*) AS "N"
FROM
sos.rv_patients
WHERE
intakedate BETWEEN '2004-01-01' AND '2004-12-31'
GROUP BY
zip
ORDER BY
zip
Next, let’s make it a little more interesting by breaking the results down further by year and month:
SELECT
zip,
YEAR(intakedate) AS "Yr",
MONTH(intakedate) AS "Mon",
COUNT(*) AS "N"
FROM
sos.rv_patients
WHERE
intakedate BETWEEN '1990-01-01' AND '2005-12-31'
GROUP BY
zip,
"Yr",
"Mon"
ORDER BY
zip,
"Yr",
"Mon"
You could, of course, change the order of the columns in the SELECT clause and in the ORDER BY line
to reorganize the output.