Question : Outer join issues when trying to build query with continuous time line

Hi,

I'm trying to write a query using an outer join with a date table to establish a continuous timeline for charts even when nulls are encountered.  The query I'm working on is something along the lines of:

select a.region,
           a.country,
           a.city,
           a.order,
           b.calendar_date
from calendar_table b left outer join table_order a
on b.calendar_date = a.date
where b.calendar_date >= to_date('20090101', 'YYYYMMDD')

What I'm finding though is that the results seem to coming from an inner join where dates are shown only for existing dates from table_order.  The intent was to be able to use the output of this query in Crystal Reports to provide different views of orders based on region, country and city while having a continuous time line for each using the range specified.

Thanks in advance.

Answer : Outer join issues when trying to build query with continuous time line

i think to do what you are looking for, your "left outer table" (Calendar_Table) might need to contain all possible combinations for each calendar date. I.e.:

Calendar Table would have columns: Calendar_Date, Region, Country, City
You would Left Join on all 4 columns.

What you have right now would work for a report that only shows data by Date.

You might want to google CROSS JOIN - it would produce an intentional cartesian result set that gives "all possible combinations" per date,region, country, and city.
Random Solutions  
 
programming4us programming4us