I have the following statement in SQL Server where I am using pivot:
Select YR, [1] As Beginning, [2] As Inter, [3] As Advanced, [4] As AdvHigh,Campus
From    
    (Select YR, Rating, StudentId, Campus 
        from mytable
        Where YR = '2014'
    ) As Data
    PIVOT   (Count(StudentId)
            For Rating IN ([1], [2], [3], [4])
    ) As Pvt
Now I am trying to write the same query in Postgresql (I am a newbie to postgresql). I have looked at tablefunc but am not exactly sure how to use it yet.
Any help will be great!
 
    