3,499
社区成员
发帖
与我相关
我的任务
分享
借用楼上大哥的数据啦。
SELECT (case
when Chinese >= 80 then
'优秀'
when Chinese < 80 and Chinese >= 60 then
'及格'
else
'不及格'
end) AS Chinese,
(case
when Math >= 80 then
'优秀'
when Math < 80 and Math >= 60 then
'及格'
else
'不及格'
end) AS Math,
(case
when English >= 80 then
'优秀'
when English < 80 and English >= 60 then
'及格'
else
'不及格'
end) AS English
from (select *
from t pivot(max(score) for course in ('语文' as Chinese, '数学' AS Math, '英语' AS English)))WITH t as (
SELECT '语文' course,88 score from dual
union
SELECT '数学' course,67 score from dual
union
SELECT '英语' course,55 score from dual
)
SELECT (case when 语文>=80 then '优秀' when 语文<80 and 语文>=60 then '及格' else '不及格' end) 语文,
(case when 数学>=80 then '优秀' when 数学<80 and 数学>=60 then '及格' else '不及格' end) 数学,
(case when 英语>=80 then '优秀' when 英语<80 and 英语>=60 then '及格' else '不及格' end) 英语
from (select
MAX(decode(course, '语文', score, NULL)) AS 语文,
MAX(decode(course, '数学', score, NULL)) AS 数学,
MAX(decode(course, '英语', score, NULL)) AS 英语
FROM t);