Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Row count by Week, Month, Year

RichardSquiresJan 17 2005 — edited Jan 18 2005
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2005
Added on Jan 17 2005
15 comments
2,272 views