SQL Server First, Last Aggregate Functions

Writing by on Tuesday, 20 of May , 2008 at 4:01 pm

Are you getting a SQL Server error saying that FIRST or LAST are not recognized or unsupported?

Error:’FIRST’ is not a recognized built-in function name. Number:195 Severity:15 State:10

Thats because they’re not.

SELECT LotFk, FIRST(RedemptionPeriodDate) as RedemptionPeriodDate -- ERROR 
FROM InvRegister

Workaround is to use MIN or MAX

SELECT LotFk, MIN(RedemptionPeriodDate) as RedemptionPeriodDate -- VALID
FROM InvRegister

Leave a comment

Category: SQL DB

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.