tsql - How Do I Find the last value for each row in SQL Server 2008? -
sql server 2008, can see in data program have actual date or null (program still open).
i want row last value (whether date or null) each program every program in resultset.
here sample of data:
rownum programkey pgmstartdate pgmenddate ------------------------------------------ 2 1014 4/1/2005 2/28/2017 4 1014 3/1/2017 null 5 1015 3/1/2017 null 3 1015 4/1/2005 2/28/2017 6 1262 7/1/2017 null 1 1262 1/1/2012 6/30/2017
i have tried top 1
returns 1 row entire resultset.
i have tried max(pgmenddate)
again returns 1 row entire resultset.
last_value
works in sql server 2012 , newer configuration sql server 2008 , remain so.
thanks in advance
how
select max(pgmenddate), programkey table group programkey
Comments
Post a Comment