I have a table which has data is below format:
Corresponding to an ID there is a year variable which represents the first time the reading reached a steady state (in the actual data its a month day combination), there will also be data for time period before the stabilization period. The a
columns represent a measure taken in that give year. I want to create a field which would sum only those fields relevant for a given id i.e. for Id=B I want to sum columns a2015-a2019
. I want this to be done dynamically. But am not sure how to do it without using case when statements since the actual data is even more granular.
I intially tried to pivot the table at id, year and value level so i can first find the steady state time period for each id and simply sum/aggregate only those value post that but transpose feature is not available in standard-sql.