一道sql面试题
程序员文章站
2024-03-23 12:58:16
...
SELECT NAME ,
SUM(CASE WHEN class='html' THEN score ELSE 0 END ) html,
SUM(CASE WHEN class='js' THEN score ELSE 0 END) js,
SUM(CASE WHEN class='sql' THEN score ELSE 0 END) 'sql'
FROM score GROUP BY NAME ;
上面是行转列!!!!!