SELECT DECODE(u.isCredit,'Y','是','否') AS isExist FROM users u WHERE u.id =100026
select decode(sign(1-2),-1,1,2) from dual //比较大小(获得小值)
Oracle中SIGN用法
sign函数返回一个数字的正负标志 语法如下:sign( number ) number 要测试标志的数字.
1 2 3 4 5 6 7 8 9
If number <0, then sign returns-1. If number =0, then sign returns0. If number >0, then sign returns1. sign(-23) return-1 sign(-0.001)return-1 sign(0) return0 sign(0.001) return1 sign(23) return1 sig(23.601) return1
Oracle分页
1 2 3 4 5 6 7 8
select*from ( select A.*,ROWNUM rn from ( select*from tableName ) A where ROWNUM <=20 )where rn >=10
1 2 3 4 5 6 7
select*from ( select a.*,rownum rn from ( select*from USERS orderby id desc )a )b where b.rn >=1and b.rn <=100;
Oracle左联接
1 2 3 4
SELECT u.name AS UserName FROM application a LEFTJOIN users u ON u.id = a.followup_user_id WHERE a.application_no ='10512248'
Oracle批处理
1 2 3 4
insertinto students select id,name ,email ,sdate from dual union select id,name ,email ,sdate from dual union select id,name ,email ,sdate from dual