1. oracle 转译
wm_concat非标准函数,不保证以后会支持
标准写法:
with t as (select name,row_number() over(order by name) rn from 表)
select name, rn, sys_connect_by_path(name, ',') path
from t
start with rn=1 connect by prior rn+1=rn
2. oracle转数值
SELECT*FROM(SELECTkey,strFROMtablet)pivot(max(str)forkeyin('hyl','ls','ryhl','yqwd'))
3. oracle 转整型
oracle中有一个月份处理函数add_months(date,int) 返回一个date型add_months(to_date(MONTH,'yyyymm'),INTERVAL)如果需要返回MONTH一致的格式to_char(add_months(to_date(MONTH,'yyyymm'),INTERVAL),'yyyymm')
4. oracle数据转换函数
1.取整(大)
select ceil(-1.001) value from dual
2.取整(小)
select floor(-1.001) value from dual
3.取整(截取)
select trunc(-1.002) value from dual
4.取整(舍入)
select round(-1.001) value from dual
5. oracle 转换
drop table ABC; create table ABC(id number,name varchar2(50),kcName varchar2(50),score number); insert into ABC valu
drop table ABC;
create table ABC(id number,name varchar2(50),kcName varchar2(50),score number);
insert into ABC values(1,'张三','语文',88);
insert into ABC values(2,'张三','数学',68);
insert into ABC values(3,'张三','英语',78);
insert into ABC values(4,'李四','英语',78);
insert into ABC values(5,'李四','语文',88);
insert into ABC values(6,'李四','数学',79);
insert into ABC values(7,'王五','英语',74);
insert into ABC values(8,'王五','语文',58);
insert into ABC values(9,'王五','数学',98);
select * from abc;
select abc.Name,sum(decode(kcName,'语文',SCORE,null)) 语文,
sum(decode(kcName,'数学',SCORE,null)) 数学,
sum(decode(kcName,'英语',SCORE,null)) 英语
from abc group by abc.name;
结果:
NAME 语文 数学 英语
1 王五 158 198 174
2 李四 188 179 178
3 张三 188 168 178
- 相关评论
- 我要评论
-