Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL 2k5 equivalent for oracle FIRST_VALUE

Author  Topic 

korssane
Posting Yak Master

104 Posts

Posted - 2009-06-29 : 15:37:43
Hi is any body knows if there is an equivalent for
oracle FIRST_VALUE function. Here is my code to translate

CASE WHEN (FIRST_VALUE(EV) over (partition by TRID order by re_id DESC) LIKE ''%blabla'') THEN
RE_DATE
ELSE
CASE WHEN (KN_IS_ID IS NOT NULL) THEN KN_IS_BE
ELSE FIRST_VALUE(CR_DA) over (partition by TRID order by re_id DESC)
END

thanks


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-29 : 15:45:08
That would be the use of ROW_NUMBER() windowed function.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

korssane
Posting Yak Master

104 Posts

Posted - 2009-06-29 : 15:52:49
thanks for the quick reply.
is this syntax gonna :return the first value in an ordered set of values?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-29 : 16:02:28
Not directly, but there is a workaround
See http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -