SELECT _VPW.MFG_SKU,
LEFT(_VPW.Location, 2) AS shelf,
_VPW.Location,
CASE
WHEN LEFT(_VPW.Location, 2) < '07' THEN 1
WHEN LEFT(_VPW.Location, 2) > '06' AND LEFT(_VPW.Location, 2) < '13' THEN 2
ELSE 3
END + CASE
WHEN _VPW.TX > 0 THEN 0
ELSE 3
END AS bucket,
_VPW.TX
FROM products._VPW
WHERE _VPW.Location IS NOT NULL
AND _VPW.Location != ''
AND _VPW.Location != '0'
;