{"id":21,"date":"2008-05-20T16:01:29","date_gmt":"2008-05-20T23:01:29","guid":{"rendered":"http:\/\/shivdev.com\/blog\/2008\/05\/20\/sql-server-first-last-aggregate-functions\/"},"modified":"2011-05-06T07:24:49","modified_gmt":"2011-05-06T07:24:49","slug":"sql-server-first-last-aggregate-functions","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2008\/05\/20\/sql-server-first-last-aggregate-functions\/","title":{"rendered":"SQL Server First, Last Aggregate Functions"},"content":{"rendered":"<p>Are you getting a SQL Server error saying that <strong>FIRST<\/strong> or <strong>LAST<\/strong> are not recognized or unsupported?<\/p>\n<blockquote><p>Error:&#8217;FIRST&#8217; is not a recognized built-in function name.\tNumber:195\tSeverity:15\tState:10<\/p><\/blockquote>\n<p>Thats because they&#8217;re not.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT LotFk, FIRST(RedemptionPeriodDate) as RedemptionPeriodDate -- ERROR \r\nFROM InvRegister\r\nGROUP BY LotFk<\/pre>\n<p>Workaround is to use MIN or MAX<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT LotFk, MIN(RedemptionPeriodDate) as RedemptionPeriodDate -- VALID\r\nFROM InvRegister\r\nGROUP BY LotFk<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Are you getting a SQL Server error saying that FIRST or LAST are not recognized or unsupported? Error:&#8217;FIRST&#8217; is not a recognized built-in function name. Number:195 Severity:15 State:10 Thats because they&#8217;re not. Workaround is to use MIN or MAX<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/21"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":2,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":187,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/187"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}