SELECT 人名,数学成绩,语文成绩 FROM 表名 WHERE 数学成绩>60 UNION SELECT 人名,数学成绩,语文成绩 FROM 表名 WHERE 语文成绩<60
SQL> select * 2 from ( 3 select 'aa' as name,80 as mathsScore,50 as yuwenScore from dual 4 union all 5 select 'bb' as name,40 as mathsScore,70 as yuwenScore from dual 6 union all 7 select 'cc' as name,30 as mathsScore,70 as yuwenScore from dual 8 union all 9 select 'dd' as name,80 as mathsScore,50 as yuwenScore from dual 10 union all 11 select 'ee' as name,90 as mathsScore,35 as yuwenScore from dual 12 union all 13 select 'ff' as name,10 as mathsScore,10 as yuwenScore from dual 14 )tt 15 where tt.mathsScore > 60 16 or tt.yuwenScore < 60 17 order by tt.mathsScore desc;NAME MATHSSCORE YUWENSCORE ---- ---------- ---------- ee 90 35 aa 80 50 dd 80 50 ff 10 10
UNION
SELECT 人名,数学成绩,语文成绩 FROM 表名 WHERE 语文成绩<60
2 from (
3 select 'aa' as name,80 as mathsScore,50 as yuwenScore from dual
4 union all
5 select 'bb' as name,40 as mathsScore,70 as yuwenScore from dual
6 union all
7 select 'cc' as name,30 as mathsScore,70 as yuwenScore from dual
8 union all
9 select 'dd' as name,80 as mathsScore,50 as yuwenScore from dual
10 union all
11 select 'ee' as name,90 as mathsScore,35 as yuwenScore from dual
12 union all
13 select 'ff' as name,10 as mathsScore,10 as yuwenScore from dual
14 )tt
15 where tt.mathsScore > 60
16 or tt.yuwenScore < 60
17 order by tt.mathsScore desc;NAME MATHSSCORE YUWENSCORE
---- ---------- ----------
ee 90 35
aa 80 50
dd 80 50
ff 10 10
区号和邮政编码这样排序还是混乱的,不能先是符合区号的数据在前,符合邮政编码的数据在后.
还有别的写法吗?
不会还继续宣传是你自己做的吧?不过我猜你一定特别喜欢http://www.java2s.com/
不然怎么抄袭人家的内容连接到自己的网站呢?
看更多更详尽的内容,请到http://www.java2s.com/