Skip to content
Advertisement

Dynamically SELECT a column based on value of row at first of month

The following query:

Returns the following sample data:

Where on the first of the month, Confirmed = Y, I need to return the Declared column for that month.

Note, Confirmed = Y will only exist on the first of the month. That column is blank in all other cases

Otherwise, I need to return each Interim column for the month.

Thus far, I have been able to return the SUM of either column, but not the individual values.

The expected output given the data at the top is as follows

Advertisement

Answer

This took me way longer than it probably should have.

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