FunkyBunch
Instructor
Hello All,
I am currently creating a view and was wondering if it was possible to use an in statement within a case statement. Here is my current SQL:
************************************************************
select access_equip_Fw,
case
when (date_mounted_Equipment_removed_fw is null) and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)>1)) then 'Transfer'
when Date_mounted_equipment_removed_fw is not null and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)>1)) then 'Transfer'
when Date_Mounted_equipment_removed_fw is null and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)=1)) then 'Addition'
When (Archive_status_fw = 'A') then 'Deletion'
Else ''
end AS sg
from user_Defined20_fw
group by date_mounted_equipment_removed_fw, access_equip_Fw, archive_status_fw
***********************************************************
The select sub-querys do return more than one value, but that should be ok within an IN statement.
Thanks,
I am currently creating a view and was wondering if it was possible to use an in statement within a case statement. Here is my current SQL:
************************************************************
select access_equip_Fw,
case
when (date_mounted_Equipment_removed_fw is null) and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)>1)) then 'Transfer'
when Date_mounted_equipment_removed_fw is not null and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)>1)) then 'Transfer'
when Date_Mounted_equipment_removed_fw is null and (in (select count(access_equip_fw)
from user_Defined20_Fw group by access_equip_fw having count(access_equip_fw)=1)) then 'Addition'
When (Archive_status_fw = 'A') then 'Deletion'
Else ''
end AS sg
from user_Defined20_fw
group by date_mounted_equipment_removed_fw, access_equip_Fw, archive_status_fw
***********************************************************
The select sub-querys do return more than one value, but that should be ok within an IN statement.
Thanks,