答案 0 :(得分:2)
选择工具箱,将矩阵拖动到设计窗格中 选择报告数据,将subject_name拖动到行中,将主题状态拖到列中,将student_count拖到数据中。 预习。 快乐构建和部署时。
答案 1 :(得分:0)
使用CASE EXPRESSION
的条件聚合:
SELECT t.subject_name,
MAX(CASE WHEN t.subject_status = 1 THEN t.student_count END) as first,
MAX(CASE WHEN t.subject_status = 2 THEN t.student_count END) as second,
MAX(CASE WHEN t.subject_status = 3 THEN t.student_count END) as third,
MAX(CASE WHEN t.subject_status = 4 THEN t.student_count END) as fourth
FROM YourTable t
GROUP BY t.subject_name
答案 2 :(得分:0)