Pivot on datetime with matching multiple column I have the following table with column school, state, subject and timedate.


I would like to have output with column school, state, act and english


filter subjects to only Act and English
pivot table to match school and state




I did tried but all queries are not work. Hopefully someone may help. Thanks.
Quickly:

select school, state, Act, English, History
from (select school, state, subject, timedate
      from data) as pivotdata
         pivot (max(timedate) for subject in (Act, English, History)) as P


Should work