you can try this one now...
;with cte as
(
SelectiSchoolYearCode
,dtCalendarDay
,iCalendarDatCategoryID
,vcCalendarCategoryCode
,ROW_NUMBER() OVER(Partition By iSchoolYearCode, iCalendarDatCategoryID Order by dtCalendarDay) RowNumber
From#Temp1
)
SelectiSchoolYearCode
,Max(Case
When vcCalendarCategoryCode = 'Quarter Start Day' Then dtCalendarDay
End) As [Quarter Start]
,Max(Case
When vcCalendarCategoryCode = 'Quarter Grade Closing' Then dtCalendarDay
End) As [Quarter end]
Fromcte
Group By RowNumber, iSchoolYearCode
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/