decode vs case
Livio, February 22, 2007 - 3:22 am UTC
Alternatively, we could replace decode with case:
select tab1.c1, case nvl(tab2.c2, -1) when -1 then 'N' else 'Y' end
from tab1,
(select distinct c2 from tab2 where c22 is null) tab2
where tab1.c1 = tab2.c2(+)
order by tab1.c1;
February 22, 2007 - 8:50 am UTC
alternatively you could do a better case
...
case when tab2.c2 is null then 'N' else 'Y' end
......
Philip Lee, February 22, 2007 - 1:18 pm UTC
Tom,
Thank you very much! It produced the same result as my original query but your query is much simpler and easier to maintain.
Inline view is very handy.
Thank You,
Philip
union query
A reader, March 08, 2007 - 10:19 am UTC
Tom,
Any suggestion on how to improve this query. Can I do better not using the union all.
SELECT TO_CHAR(response_ref_id),schedule_id,customer_id,mtn,campaign_id,
bill_account_number,owning_region_cd,response_status, response_sent_dt,
response_received_dt,response_received_code, validate_flag,
triggering_event_id,channel_id,channel_user_id,channel_location,
SELECTED_CHECKLIST_ITEM,SELECTED_OPTIONLIST_ITEM,delete_ind
FROM rm_response_e_sp a
UNION ALL
SELECT TO_CHAR(response_ref_id),
schedule_id,customer_id, mtn,campaign_id,bill_account_number, owning_region_cd,
response_status, response_sent_dt, response_received_dt,response_received_code,
validate_flag, triggering_event_id,channel_id, channel_user_id,
channel_location,SELECTED_CHECKLIST_ITEM,SELECTED_OPTIONLIST_ITEM,delete_ind
FROM rm_response_w_sp b
March 08, 2007 - 11:12 am UTC
looks awesome to me
I mean - well - you want all rows from two tables. It is about the simplest thing in the planet SQL wise. not too much you can do to such a simple query short of making it more complex!
YAHOOSTRONGERDRIVER
CiprianoCapote, February 10, 2014 - 2:22 am UTC