标签: mysql sql database
我将第一个表存储在数据库中,如图所示,我必须对其应用查询才能像第二个表一样显示它
答案 0 :(得分:0)
以下是使用conditional aggregation的一种选择:
conditional aggregation
select subject, max(case when exam = 'Mid1' then marks end) as Mid1, max(case when exam = 'Mid2' then marks end) as Mid2 from yourtable group by subject