Skip to content
Advertisement

How can I Create Multiple DATEDIFF Columns?

I would like to calculate the DATEDIFF between each of the different ranges represented by the NewValue column below.

I would like the output to be something like this:

I’ve tried the following code to create one of these columns, but I get all 0s. How can I fix this code and make it work for any number of columns? I’m thinking CASE WHEN, but not sure how to integrate. Thank you!!!

Advertisement

Answer

Use conditional aggregation:

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