username skill mark
x writing 10
x reading 11
a writing 15
a reading 14
我希望得到这样的o / p:
x 10 11
y 15 14
答案 0 :(得分:1)
条件聚合是要走的路:
SELECT t.username,
MAX(CASE WHEN t.skill = 'writing' THEN t.mark END) as writing_mark,
MAX(CASE WHEN t.skill = 'reading' THEN t.mark END) as reading_mark
FROM YourTable t
GROUP BY t.username
答案 1 :(得分:0)
select username,skill,mark from Your_table;#this fetches only 3
Or
select * from Your_table; #this will fetch all fields of your table