Question : Can I used decode in this scenario


I have the following query.

I need to add an extra column in the query where I have indicate the value as 'Active' when
pa.workflowstatus between 100 and 400
otherwise, it should be NULL

Can I use Decode here.. Please let me know how I can do this
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
select ms.pid, pe.eligid,ms.fname,ms.lname,ms.dob,me.coveragebegindate,
pa.programid, rf.programname,pa.workflowstatus,rfw.programworkflowstatusdesc
from pideligid pe,memberelig me, programassignment pa, membership ms,rfprogram rf, rfprogramworkflowstatus rfw
where pe.clientid=301012
and pe.pid=ms.pid
and ms.pid=me.pid
and ms.pid=pa.pid
and pa.programid=rf.programid 
and me.coverageenddate is null 
and me.pid not in (select pid from bcbsmi.memberelig@ingest)
--and pa.workflowstatus between 100 and 400
and pa.workflowstatus=rfw.programworkflowstatusid
order by ms.pid

Answer : Can I used decode in this scenario

no, decode can't do a "between",  but you can use case

select ms.pid, pe.eligid,ms.fname,ms.lname,ms.dob,me.coveragebegindate,
pa.programid, rf.programname,pa.workflowstatus,rfw.programworkflowstatusdesc,
case when pa.workflowstatus between 100 and 400 then 'Active' end
Random Solutions  
 
programming4us programming4us