Can you do it like this? I am aliasing the column names to Date1, Date2, Date3.WITH cte AS( SELECT field1, field2, ROW_NUMBER() OVER (PARTITION BY field1 ORDER BY cast(field2 AS date)) rownum FROM YourTable)SELECT Field1, [1] AS Date1, [2] AS Date2, [3] AS Date3FROM ctePIVOT( MAX(field2) FOR rownum IN([1],[2],[3]))P
If you have an unknown number of dates, then you would either need to have a lot of columns so the largest possible case can be taken care of, OR, use dynamic pivoting - see Madhivanan's blog here: http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx