FIRST aggregate function which I can use with HAVING clause
问题 I have a weird requirement which I need to use inside my Stored Procedure in SQL Server 2008 R2. I need a FIRST aggregate function which returns the first element of a sequence and I will use that with HAVING clause. Let me give you an example: DECLARE @fooTable AS TABLE( ID INT, CategoryName NVARCHAR(100), Name NVARCHAR(100), MinAllow INT, Price DECIMAL(18,2) ); INSERT INTO @fooTable VALUES(1, 'Cat1', 'Product1', 2, 112.2); INSERT INTO @fooTable VALUES(2, 'Cat2', 'Product2', 4, 12.34);