Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Outer Joins with standard Oracle functions?
I'm trying to produce a query that will give me a count of records for each
month for the past 12 months, defaulting to 0 if there are no records.
I have a subquery to produce the month beginnings (table not possible atm). The records in the table I'm counting have a full date/time.
My query is...
select company,monthbeginning,count(*)
from mytable a,
monthbeginningssubquery b
where b.date=to_date(to_char(a.thedate,'YYYYMM'),'YYYYMM')(+)
group by company,monthbeginning
Unfortunately the outer join isnt accepted by oracle, because it's on a to_date.
Any suggestions? I dont have permissions to write a package/function to handle this, have to be pure sql. This is Oracle 8.1.7.latest STD ed. If there's a better way to do this kinda thing I'm all ears!
Thanks
J
Received on Thu Jan 22 2004 - 06:04:02 CST
![]() |
![]() |