Friday, 21 January 2022

If Else clause or decode or Case in Where clause

 If Else clause or decode or case in Where clause


We are not going to check here if else or decode or case but i am going to tell u an alternate.........


Suppose we need workorder's with status =APPR  else I need WAPPR but i have to give preference to APPR solution

select * from maximo.workorder where status in (APPR,WAPPR) order by status desc


Now suppose we have 2 records one is appr and one is wappr

Then modify this query like 
Select * from maximo.workorder where workorderid in (
select workorderid  from maximo.wokrorder where workorderid in (select workorderid from maximo.workorder where status in (APPR,WAPPR) order by status desc
)  where rownum<2)


So we are using here rownum to display approve before wappr ............


If we have only wappr records then our subquery will return wappr records only and with  rownum<2 

we will get only one record....................


This you can use in relationship of maximo where u have to find 1 record only as fetch 1st alternate.......

1 comment:

  1. CasinoDaddy - drmcd
    Discover 구리 출장샵 over 삼척 출장안마 500 real money casinos and 속초 출장샵 gambling games at CasinoDaddy. Join today and start earning points for playing 논산 출장마사지 & win 서울특별 출장안마 real money!

    ReplyDelete