Hey all,
I got this SP that I am using in SQL 2000.
This returns records but I need to make sure the record that is returning is the last record for that given year. Some contractors could recieve a new status after the returned record therefore what is returning isn't very accurate.Code:SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO ALTER PROCEDURE dbo.usp_Approved_Subs @p_Status NVARCHAR(25), @p_Year INT AS SELECT pv.VendorName as Subcontractor, pv.SentBy_Name as InvitedByName, pv.SentTo_Name as ContactName, al.ActionDate as DateApproved, al.fk_Action as Status, al.ActionDate as ActionDate FROM PreQual_Vendors pv LEFT OUTER JOIN ActionLog al ON pv.pk_PreQual_Vendor = al.fk_PreQual_Vendor WHERE al.ExtraText = @p_Status AND DATEPART(yyyy, al.ActionDate) = @p_Year ORDER BY pv.VendorName GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
How would I return the max date that meets the status and year condition?
Thanks




Reply With Quote