so you want only four date values? if yes useSELECT student_id,name,[1] AS Cnv1,[2] AS Conv2,[3] AS Conv3,[4] AS Conv4FROM(SELECT ROW_NUMBER() OVER (PARTITION BY student_id ORDER BY datefield) AS Rn,*FROM Students sJOIN Mentors mON m.student_id = s.student_id)tPIVOT (MAX(datefield) FOR Rn IN ([1],[2],[3],[4]))p
I've assumed table and column names as i dont know the actual names. make sure you replace them with correct names in your actual query------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/