imported_Tarzan

Junior Member
Sep 11, 2004
14
0
0
Hi There,

Can you please help in completing a Query, I will give a brief intoduction on the problem.

I have to calculate the date by using a parameter Status if the status is 1 then it has to fetch the value of the record created and the when the status is 1.

I have written a Query for this and is working fine, now I need to also include another status 2. i.e if the status is 1 then it has to fetch some records and if it is 2 then it will fetch different records.

Can you please suggest how do i use the option OR in SQL

vw_s_code.VALUE,(CASE when(new_vw_a.status_code =1 )
then floor(sysdate-(select entry_time from n_s_s nss
where status_code_pkid = 1 and nss.a_P = new_vw_s.PKID))

else floor(sysdate-new_vw_s.c_DATE)
END) Days_Since_Open,

I have tried using UNION its not working.

For the above I want to add option 2 i.e Status 1 or 2

Thanks in advance

Cheers:cool:
 

edmicman

Golden Member
May 30, 2001
1,682
0
0
select entry_time from n_s_s nss where (status_code_pkid = 1 OR status_code_pkid=2) and nss.a_P = new_vw_s.PKID

OR you could probably do

select entry_time from n_s_s nss where status_code_pkid in (1, 2) and nss.a_P = new_vw_s.PKID
 

imported_Tarzan

Junior Member
Sep 11, 2004
14
0
0
Hey Thanks for the update, actuall I was looking for single instance to be returned so I was not able to use the option IN, and it was not working with the option OR.

I some how managed to get it I have used another When statement with this time the value as 2

(CASE when(new_vw_a.status_code =1 )
then floor(sysdate-(select entry_time from n_s_s nss
where status_code_pkid = 1 and nss.a_P = new_vw_s.PKID))

when(new_vw_a.status_code =2 )
then floor(sysdate-(select entry_time from n_s_s nss
where status_code_pkid = 2 and nss.a_P = new_vw_s.PKID))

else floor(sysdate-new_vw_s.c_DATE)
END) Days_Since_Open,

Thanks for the update

Cheers :cool: