Look at the result below:
This is the result of the following query:
select *,
isnull(h,isnull(f,isnull(d,isnull(b,isnull(a,0))))) as y1,
isnull(h,isnull(g,isnull(f,isnull(e,isnull(d,isnull(c,isnull(c,0))))))) as y2 from valor
My difficulty is: whenever y2
presents a value of a column, y1
should always present the previous one, as is happening in line 2 of the image above.
But observing line 1 is a case, line 3 is another case and wrong cases of what I wish to do.
If someone could help me mount this query?