I have the following case statement getting the following error
Server: Msg 156, Level 15, State 1, Line 17
Incorrect syntax near the keyword 'else'.
Any ideas? Thanks Much
case when detail.rec_stus_id = '1' then
case when bg.bus_grp_id = 1 and demand.mfg_fclt_code in ('cg','ci','ac') then
case when (m.invt_cost = 0 or m.invt_cost is null) then (gs.sllr_figqy_conv_fc * detail.shpd_qty)
else (gs.sllr_figqy_conv_fc * detail.shpd_qty) * (m.invt_cost)
end
end
end
else
case when detail.rec_stus_id <> '1' then
case when bg.bus_grp_id = 1 and demand.mfg_fclt_code in ('cg','ci','ac') then
case when (m.invt_cost = 0 or m.invt_cost is null) then (gs.sllr_figqy_conv_fc * detail.ord_qty)
else (gs.sllr_figqy_conv_fc * detail.ord_qty) * (m.invt_cost)
end
end
end
Server: Msg 156, Level 15, State 1, Line 17
Incorrect syntax near the keyword 'else'.
Any ideas? Thanks Much
case when detail.rec_stus_id = '1' then
case when bg.bus_grp_id = 1 and demand.mfg_fclt_code in ('cg','ci','ac') then
case when (m.invt_cost = 0 or m.invt_cost is null) then (gs.sllr_figqy_conv_fc * detail.shpd_qty)
else (gs.sllr_figqy_conv_fc * detail.shpd_qty) * (m.invt_cost)
end
end
end
else
case when detail.rec_stus_id <> '1' then
case when bg.bus_grp_id = 1 and demand.mfg_fclt_code in ('cg','ci','ac') then
case when (m.invt_cost = 0 or m.invt_cost is null) then (gs.sllr_figqy_conv_fc * detail.ord_qty)
else (gs.sllr_figqy_conv_fc * detail.ord_qty) * (m.invt_cost)
end
end
end