Reputation:
I need an alternative for first_value
in SQL Server 2008.
select distinct
spisznacka,
first_value(VdruhStavRizeni) over (partition by spisZnacka order by id desc) as stav
from
isirshort
where
VdruhStavRizeni !=''
I need spisznacka
and last not null value of VdruhStavRizeni
... 1 spisznacka
has 1 VdruhstavRizeni
Thanks for answers.
Upvotes: 0
Views: 822
Reputation: 1270001
You can do this with row_number()
and some more logic, like this. I think you want:
select spisznacka, VdruhStavRizeni
from (select spisznacka, VdruhStavRizeni,
row_number(VdruhStavRizeni) over (partition by spisZnacka order by id desc) as seqnum
from isirshort
where VdruhStavRizeni <> ''
) sv
where seqnum = 1;
Upvotes: 1