Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> SQL syntax hel!

SQL syntax hel!

From: Mike <mike_at_nospam.com>
Date: Mon, 08 Jan 2001 19:08:59 GMT
Message-ID: <ffo66.12471$0s3.618050@typhoon.columbus.rr.com>

I wonder if someone could help me to resolve the following problem. I need to join 3 table:
OUTAGE: unit, line, xdate, status, outage_id DISPATCH: d_code, d_outage_id, d_truck_id, d_date TRUCK: t_code, t_truck_id, t_truck_name

select status, t_ruck_name|| '::' ||d_truck_id|| '::' ||d_date ''INFO" from OUTAGE,DISPATCH,TRUCK
where xdate>sysdate-1 and (
(status='0' and outage_id is null) or
(status='1' and d_code='AAA' and d_code=t_code and d_outage_id=t_outage_id
and d_truck_id=t_truck_id)
)

The problem is when STATUS='0' ==> OUTAGE_IS the column INFO should not have any values.
(it cannot be connected to DISPATH.d_outage_id ( d_outage_id is never NULL)
But because I am dooing something worng (that is I am sure of :-) with a 3 table join, INFO always returned with some value.

Basicly, result should be:
STATUS INFO

---------    -----------------------------
            0
            0
            1    JonhDoe::truck_1::12-jan-00
            1    RickTop::truck_2::14-jan-00

(But the above query returns:

STATUS INFO

---------    -----------------------------
            0    JonhDoe::truck_1::12-jan-00
            0    JonhDoe::truck_1::12-jan-00
            0    RickTop::truck_2::14-jan-00
            0    RickTop::truck_2::14-jan-00
            1    JonhDoe::truck_1::12-jan-00
            1    RickTop::truck_2::14-jan-00

I would appreciate your help.
Thanks.
Mike Received on Mon Jan 08 2001 - 13:08:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US