Making `group by` result in multiple columns
问题 I have a ( Postgres ) query with a usual group by clause: select extract(year from a.created) as Year,a.testscoreid, b.irt_tlevel, count(a.*) as Questions from asmt.testscores a join asmt.questions b on a.questionid = b.questionid where a.answered = True group by Year,a.testscoreid, b.irt_tlevel order by Year desc, a.testscoreid The column b.irt_tlevel has values low , medium and high , all these results are in a row-format, for example: Year TestScoreId Irt_tlevel Questions 2015 1 Low 2 2015