How to fetch the latest data depending on year of all product ?

How to get the record which is marked in red ? 

Note : there is many BaaN product , I have put an example showing with 2 Baan Product .

February 9th, 2015 4:25am

Try the below:

;With cte as 

(Select *, Row_Number()Over(partition by BaaN Order by [Contract Start Date] desc) Rn 

From Tablename)

Select * From cte where rn=1


Free Windows Admin Tool Kit Click here and download it now
February 9th, 2015 4:30am

SELECT t.*
FROM Table t
WHERE NOT EXISTS 
(
SELECT 1
FROM Table 
WHERE TENDER = t.TENDER
AND BaaN = t.BaaN
AND [CONTRACT START DATE] > t.[CONTRACT START DATE]
)

February 9th, 2015 5:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics