Thing is, its always sorted that way. So if there are nulls, they are at the bottom. This can be a result:
columnX
100
86
85
70
null
null
and this as well:
columnX
100
86
85
70
So there can be nulls or not, in any case, I want to find the first not null rows, 70 in the above examples. I think the CTE is a nice start...but something is still missing. This is how I get those rows:
select columnx from mytable where someid = 12345
So the numbers in columnx all belong together (because someid). I really have to get the first not null row from that result. I cant just look for the first row that is not null from the whole columnx, I have to use a condition (where someid = 12345) before. The 70 is just an example, it can be 90 as well, so I cant get the minvalue from the results. The nulls are always at the bottom, the rest can be unsorted. This can be a result as well:
columnX
100
23
80
78
null
null
In that case I want the 78.
Thanks