I have the following table with column school, state, subject and timedate. enter image description here

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

enter image description here

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



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

enter image description here

  • can you show a picture of the result of this query? just to see if it matches the expected result May 25 '20 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.