You need the IN clause in the correlated subquery too, or use the SQL Server 2005 variantCREATE VIEW MX_Largest_Gift_ViewASSELECT GiftID, GiftEffDat AS largestGiftDate, GiftType AS largestGiftType, GiftAmount AS largestGiftAmount, GiftAmtPlg AS largestGiftAmtPlg, GiftAcctNum AS largestGiftAcctNumFROM ( SELECT GiftID, GiftEffDat, GiftType, GiftAmount, GiftAmtPlg, GiftAcctNum, ROW_NUMBER() OVER (PARTITION BY GiftID ORDER BY GiftAmount DESC) AS recID FROM Gifts WHERE GiftType IN ('g', 'y', 'b', 'c', 'p') ) AS dWHERE recID = 1
Create view MX_Largest_Gift_Viewasselect g.giftid , gifteffdat as largestgiftdate, gifttype as largestgifttype, giftamount as largestgiftamount, giftamtplg as largestgiftamtplg, giftacctnm as largestgiftacctnm from gifts_full as gwhere gifttype in ('g','y','b','c','p')and giftamount=(select max(giftamount)from gifts g1 where g1.giftid = g. giftid and gifttype in ('g','y','b','c','p'))
E 12°55'05.63"N 56°04'39.26"