Skip to content
Advertisement

Assign min value or max value based on a value change

HAVE

WANT (Get min date when ct_val within the ID group is 0 across that ID group OR get max date within the ID group where ct_val is not 0 (that is it may contain a 1) across that ID group). For instance, if the ct_val within an ID group is 1, pick the maximum dt where ct_val within that group is 1

Advertisement

Answer

You can try to use MAX condition aggragte window function with FIRST_VALUE window function to get your logic.

Query 1:

Results:

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