LEFT JOIN (+) problems

From: Philippe Legault <p_inkfloyd_at_softhome.net>
Date: 22 Jul 2002 14:57:14 -0700
Message-ID: <f123b19b.0207221357.1648f83e_at_posting.google.com>


Hello all, I seem to be having a bit of a problem with the (+) (JOIN) thing. Here's the scenario:

I have a table, intrvl_hh, that has one field (INTERVAL) and contains all the half hours of the day in military time, such as: 00:00, 00:30, 1:00, 1:30, and so on as VARCHAR2(5). I have another table, a, that has 3 fields such as

create table a (daterapport date,interval VARCHAR2(5),calls number);

Now I've inserted 3 test records with the commands:

insert into a values (TO_DATE('4-Jul-2002','dd-mon-yyyy'),'06:30',57);
insert into a values (TO_DATE('5-Jul-2002','dd-mon-yyyy'),'06:30',23);
insert into a values (TO_DATE('5-Jul-2002','dd-mon-yyyy'),'09:30',12);

Now I want to have a "left join" such that _all_ the intervals (half-hours) of the day show-up and also the records from table a where there is data. A select statement like this does the job:

select * from intrvl_hh,a where intrvl_hh.interval=a.interval(+) order by intrvl_hh.interval;

Now if I only want the ones from July 5th 2002, I would think of doing something like:

select * from intrvl_hh,a where intrvl_hh.interval=a.interval(+) AND a.daterapport = TO_DATE('5-Jul-2002','dd-mon-yyyy') order by intrvl_hh.interval;

Unfortunately, this only returns me the 2 records and not all the half-hours of the day that I also want... am I missing something here?

Thanks,

Phil Received on Mon Jul 22 2002 - 23:57:14 CEST

Original text of this message