Skip to content
Advertisement

Was column ever equal to x in sql

I have a dataset that looks similar to this:

I want to check if the description was ever equal to X, grouped by unique ref. I would also like it to have a separate column for the date in which description was X. If the unique ref has been X more than once then the date would be the most recent.

which would give an output similar to:

Advertisement

Answer

You can use window functions:

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