SQL - value for the last date -
sounds easy guess of guys can't find solution due poor sql knowledge.
i have request:
- first 3 columns
margin
cannull
i want create column last application margin
rule:
- if margin null last value no null find.
screenshot here:
thanks lot
use isnull
/coalesce
, subquery:
select scope_enum_compete, margin, date_test, isnull(margin, ( select top 1 margin dbo.tablename t2 margin not null , t2.date_test < t1.date_test order date_test desc )) [last applicable margin] dbo.tablename t1
Comments
Post a Comment