I'm looking to find a cleaner way of doing this. I'm looking to find all of the tracking numbers where one line meets a condition and then assign a value to every row of that tracking number. I'm currently doing this with case logic but only get halfway there without creating more statements. Way to do this cleanly in one?
End result would look like:
The sql below only gives me the the case value for the line where I'd want it for every line in the tracking number where it applied.
select [Tracking Number] ,
CASE WHEN [Tracking Number] in
(Select distinct [Tracking Number] where ([Row Description] like '%A%') Then '1'
WHEN [Tracking Number] in
(Select distinct [Tracking Number] where ([Row Description] like '%B%') Then '2'
ELSE '' END as Row_Description
from dwh.mytable
Thanks!