随笔分类 - Oracle实验例子
摘要:--方法1: with tmp as ( select '按时的撒旦123元(其中含存款11元)' name from dual union all select '一类似的预存9600元(新势力)' from dual ) select name,trim(translate( substr(name,1,instr(name...
阅读全文
摘要:--创建测试表 create table test(id number, name varchar2(20)); insert into test(id, name) values(1,'10'); insert into test(id, name) values(1,'10'); insert into test(id, name) values(2,'20'); insert into t...
阅读全文
摘要:--实现1: select r1 || '*' || r1 || '=' || r1 * r1 A, decode(r2, '', '', r2 || '*' || r1 || '=' || r2 * r1) b, decode(r3, '', '', r3 || '*' || r1 || '=' || r3 * r1) C, decode(r4, ''...
阅读全文
摘要:--max(字段名)中的"字段名"的数据类型是字符型的,"字段名"+ 0后,oracle会隐式的转换成数字型 --测试 create table Test (a varchar2(20)); insert into Test(a) select '1' from dual union all select '2' from dual union all ...
阅读全文
摘要:已知数据如下:PC E D工 5 2016-09-01工 6 2016-09-30公 5 2016-09-01公 6 2017-09-30 加入查询开始日期是2016-09-01,结束日期2016-10-07 希望将上面数据变成:PC E S N工 5 2016-09-01 2016-09-30工
阅读全文
摘要:题目1:根据第一二列,计算出第三列。即:求每组KH_VALUE状态(1和0)变化的最小时间 题目2:按照c1的顺序,求出c2状态发生变化的开始及结束位置。 已知tmp表数据如下: c1 c2 1 1 2 1 4 1 5 0 6 0 7 0 8 1 9 1 10 1 11 1 12 1 13 0 14
阅读全文
摘要:--创建全局临时表 create global temporary table temp_table(id number,name varchar2(20)) on commit preserve rows; --只在同一个会话中有效 --测试代码如下: SQL> create global temporary table temp_table( 2 id number, 3 name var...
阅读全文

浙公网安备 33010602011771号