Skip to content
Advertisement

SQL creating a column for only the latest ID with an additional condition

I’m working with a SQL Server table where I have the following

Can anyone tell my how can I use SQL to add a column that calculates the age of the latest process for each ID, ignoring all ID’s where the Stopper says “DO_NOT_USE” please?

I also need the whole table

Advertisement

Answer

You can use row_number with not exists :

EDIT : Using window function :

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement