Row count by Week, Month, Year
I have a requirement to count a number of records, by type, for the current week, month and year. I hoped to be able to achieve this using the following:
SELECT COUNT(mc.date_added) OVER (
PARTITION BY mc.type_added
ORDER BY mc.date_added
RANGE BETWEEN v_week_start_date FOLLOWING AND v_week_end_date PRECEDING) week_type_count
FROM my_records mc
with a separate line for each period. However, I get an error saying that it expected a number but got a date. I've tried partitioning by the date instead of the type but I get the same error. Can someone advise me as to where I might be going wrong?
Thanks
Richard