• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SQL Query

imported_Tarzan

Junior Member
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😎
 
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
 
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 😎
 
Back
Top