I have a query, listed below, that I need to place a CASE statement in the WHERE clause.
I need to match two fields a.location=c.location IF c.item_tracking_option = 'serialized". If item_tracking_location does not equal "serialized" then I do not want to match the two location fields.
I was trying something like this
where c.location = case when item_tracking_option = 'serialized' then c.location='tsp' else null end
but it is not working.
select a.item_number, item_description, item_class_code, a.location, a.bin, case when item_tracking_option = 'none' then a.quantity when item_tracking_option = 'serial numbers' then c.qty end as quantity, selling_u_of_m, item_tracking_option, xboxupc, serial_num, case when a.bin like '%.p%' and a.bin not like 'te%' then substring(a.bin, 6,3) when a.bin like 'wh%' then substring(a.bin, 6,2) else a.bin end as section, case when a.bin like 'wh%' then substring(a.bin, 4,1) end as pickable from spvinventorymultibin a
join spvitemmaster b
left join spvinventoryserialnum c
on a.item_number=c.item_number and a.bin=c.bin
where quantity>0 and a.location='tsp'
order by a.location, bin, a.item_number