结构转化的 sql 语句为: create or replace view v_sale(year,month1,month2,month3,month4,month5,month6,month7,month8,monthArray,mo nth10,month11,month12) as select substrb(month,1,4), sum(decode(substrb(month,5,2),01,sell,0)), sum(decode(substrb(month,5,2),02,sell,0)), sum(decode(substrb(month,5,2),03,sell,0)), sum(decode(substrb(month,5,2),04,sell,0)), sum(decode(substrb(month,5,2),05,sell,0)), sum(decode(substrb(month,5,2),06,sell,0)), sum(decode(substrb(month,5,2),07,sell,0)), sum(decode(substrb(month,5,2),08,sell,0)), sum(decode(substrb(month,5,2),0Array,sell,0)), sum(decode(substrb(month,5,2),10,sell,0)), sum(decode(substrb(month,5,2),11,sell,0)), sum(decode(substrb(month,5,2),12,sell,0)) from sale group by substrb(month,1,4);
八:length()
length()与 lengthb()区别 oracle 中 length()与 lengthb()区别
SQL> select length('阿猪') from dual; LENGTH('阿猪') -------------2 SQL> select lengthb('阿猪') from dual; LENGTHB('阿猪') --------------4
区别:length 求得是字符长度,lengthb 求得是字节长度。
The "length" functions return the length of char. LENGTH calculates length using characters as defined by the input character set. LENGTHB uses bytes instead of characters. LENGTHC uses Unicode complete characters. LENGTH2 uses UCS2 codepoints. LENGTH4 uses UCS4 codepoints
九:TRIM()、ltrim() 、
1.先看一下 Oracle TRIM 函数的完整语法描述 TRIM([ { { LEADING | TRAILING | BOTH } [ trim_character ] | trim_character } FROM ] trim_source ) 以 上 语 法 引 自 于 Oracle 10gR2 官 方 文 档 : http://download.oracle.com/docs/ ...
0/img_text/trim.htm 单从这个语法定义上我们就可以看出,小小的 Oracle TRIM 函数蕴含了更多可定制的功能。一 一展示,供参考。 2.最简单的用法开始 不使用任何参数: gloria@www.dweye.net> select trim (' DWEYE ') "TRIM e.g." from dual; TRIM e.g -------DWEYE 这也是最常见的一种使用方法, 都使用默认的参数,默认情况下 TRIM 会同时删除字符串前后出 现的空格。 3.其实第一种常用的方法等同于下面带有“BOTH”参数的写法 gloria@www.dweye.net> select trim (both from ' DWEYE ') "TRIM e.g." from dual; TRIM e.g -------DWEYE “BOTH”参数表示同时去除字符串前后所指定的内容(默认情况下删除空格) 。 4.既然试用了 BOTH 参数,我们再看一下“TRAILING”和“LEADING”参数效果 gloria@www.dweye.net> select trim (trailing from ' DWEYE ') "TRIM e.g." from dual; TRIM e.g. -----------DWEYE gloria@www.dweye.net> select trim (leading from ' DWEYE ') "TRIM e.g." from dual; TRIM