select a.OP_FL_PLAN_KEY,       
a.FLIGHT_NO,            
a.ORIGIN,                 
a.DESTINATION,           
a.SEG_DEP_DATE_TIME,     
a.SEG_ARR_DATE_TIME,    
a.DEP_DAY_CHG,            
a.ARR_DAY_CHG,         
decode(a.ac_type,'JET',c.AC_TYPE,a.ac_type)               
a.AC_GRP, b.exp_lat_date_time,
b.imp_toa_date_time,
b.spl_code from 
op_fl_plan a, op_fl_service_times b, op_ac_type c,
op_restriction d,
op_restriction_rq e
where a.op_fl_plan_key = b.op_fl_plan_key 
and a.op_fl_plan_key = e.op_fl_plan_key
and b.op_fl_service_times_key = d.op_fl_service_times_key
and a.op_fl_plan_key = c.op_fl_plan_key
and b.exp_lat_date_time >= :eldt
and b.imp_toa_date_time <= :itdt 
and b.spl_code in(:spl_code1, :spl_code2)
and b.service = :srv and a.origin = :o and a.destination = :d
and substr(a.flight_no, 1, 2) = :flight_no
and a.ac_grp in(:ac_grp)
and trunc(a.seg_dep_date_time) = :seg_dep_date
and e.spl_code in(:spl_code1, :spl_code2)
and d.spl_code not in(:spl_code1, :spl_code2)
and d.position in('E', 'I')
Regards,
�
Kamaljeet Singh (NCDB ASG)
MBT, 52 Barrack�Square, Martlesham. IP5 3RF.
Off. 01473 667170
Mob. 077 5368 5370
[EMAIL PROTECTED]
��

-----Original Message-----
Krishnaswamy, Ranganath
Sent: 10 March 2003 12:49
To: Multiple recipients of list ORACLE-L

Hi List,

        I have the below query which is very long and it contains an
UNION
clause as the query has to select ac_type from op_ac_type table if
op_fl_plan.op-ac_type = 'JET' while it should select op_ac_type from
op_fl_plan table if op_fl_plan.ac_type = 'JET'.    Is it possible to
rewrite
the query using DECODE statement or CASE statement or self joins to
return
the same result set?  If so, please let me know the same.  Any help in
this
regard is very much appreciated.

Thanks and Regards,

Ranganath

select a.OP_FL_PLAN_KEY,       
a.FLIGHT_NO,            
a.ORIGIN,                 
a.DESTINATION,           
a.SEG_DEP_DATE_TIME,     
a.SEG_ARR_DATE_TIME,    
a.DEP_DAY_CHG,            
a.ARR_DAY_CHG,         
a.AC_TYPE,               
a.AC_GRP, b.exp_lat_date_time,
b.imp_toa_date_time,
b.spl_code from 
op_fl_plan a, op_fl_service_times b, 
op_restriction d,
op_restriction_rq e
where a.op_fl_plan_key = b.op_fl_plan_key 
and a.op_fl_plan_key = e.op_fl_plan_key
and b.op_fl_service_times_key = d.op_fl_service_times_key
and a.ac_type <> 'JET'
and b.exp_lat_date_time >= :eldt
and b.imp_toa_date_time <= :itdt 
and b.spl_code in(:spl_code1, :spl_code2)
and b.service = :srv and a.origin = :o and a.destination = :d
and substr(a.flight_no, 1, 2) = :flight_no
and a.ac_grp in(:ac_grp)
and trunc(a.seg_dep_date_time) = :seg_dep_date
and e.spl_code in(:spl_code1, :spl_code2)
and d.spl_code not in(:spl_code1, :spl_code2)
and d.position in('E', 'I')
union
select a.OP_FL_PLAN_KEY,       
a.FLIGHT_NO,            
a.ORIGIN,                 
a.DESTINATION,           
a.SEG_DEP_DATE_TIME,     
a.SEG_ARR_DATE_TIME,    
a.DEP_DAY_CHG,            
a.ARR_DAY_CHG,         
c.AC_TYPE,               
a.AC_GRP, b.exp_lat_date_time,
b.imp_toa_date_time,
b.spl_code from 
op_fl_plan a, op_fl_service_times b, op_ac_type c,
op_restriction d,
op_restriction_rq e
where a.op_fl_plan_key = b.op_fl_plan_key 
and a.op_fl_plan_key = e.op_fl_plan_key
and b.op_fl_service_times_key = d.op_fl_service_times_key
and a.op_fl_plan_key = c.op_fl_plan_key
and a.ac_type = 'JET'
and b.exp_lat_date_time >= :eldt
and b.imp_toa_date_time <= :itdt 
and b.spl_code in(:spl_code1, :spl_code2)
and b.service = :srv and a.origin = :o and a.destination = :d
and substr(a.flight_no, 1, 2) = :flight_no
and a.ac_grp in(:ac_grp)
and trunc(a.seg_dep_date_time) = :seg_dep_date
and e.spl_code in(:spl_code1, :spl_code2)
and d.spl_code not in(:spl_code1, :spl_code2)
and d.position in('E', 'I')
WARNING: The information in this message is confidential and may be
legally
privileged. It is intended solely for the addressee.  Access to this
message
by anyone else is unauthorised.  If you are not the intended recipient,
any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be
unlawful.
Please immediately contact the sender if you have received this message
in
error. Thank you.
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Krishnaswamy, Ranganath
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

*********************************************************
Disclaimer

This message (including any attachments) contains 
confidential information intended for a specific 
individual and purpose, and is protected by law. 
If you are not the intended recipient, you should 
delete this message and are hereby notified that 
any disclosure, copying, or distribution of this
message, or the taking of any action based on it, 
is strictly prohibited.

*********************************************************

Visit us at http://www.mahindrabt.com


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Kamaljeet  Singh
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to