zombie_man23
July 18th, 2005, 08:19 AM
I need a little help with these case statments in my where clause. I don't need to display the results of the case statements, but I do need to put them in my where clause. Any help??
select distinct(r.studentid), r.studentname, r.building,
case when r.currcode like'D%' or r.currcode like 'W%' then rc.dual1 else r.currcode end Currcode,
case when r.currcode like'D%' or r.currcode like 'W%' then rc.dual2 else '' end Dual2
from reg r, bldgtype b, regtb_curr_code rc
where
r.status = 'A' and
b.type = 1 and
r.building = b.bldg and
r.currcode = rc.code and
(
case when r.grade in ('KA','KP','KF') then 'KG' else r.grade end or
case when r.grade in ('PA','PP','PK') then 'PK' else r.grade end
)
(r.building || '*' || trim(r.grade) || '*' || trim(r.currcode)) not in
(select s.bldg || '*' || trim(s.grade) || '*' || trim(s.prog) from seats s where seats >0)
select distinct(r.studentid), r.studentname, r.building,
case when r.currcode like'D%' or r.currcode like 'W%' then rc.dual1 else r.currcode end Currcode,
case when r.currcode like'D%' or r.currcode like 'W%' then rc.dual2 else '' end Dual2
from reg r, bldgtype b, regtb_curr_code rc
where
r.status = 'A' and
b.type = 1 and
r.building = b.bldg and
r.currcode = rc.code and
(
case when r.grade in ('KA','KP','KF') then 'KG' else r.grade end or
case when r.grade in ('PA','PP','PK') then 'PK' else r.grade end
)
(r.building || '*' || trim(r.grade) || '*' || trim(r.currcode)) not in
(select s.bldg || '*' || trim(s.grade) || '*' || trim(s.prog) from seats s where seats >0)