如题,在线等
解决方案 »
- 组合索引和单个索引对数据库性能的影响
- 请问查询这样的SQL语句怎么写?
- 数据库范式理论
- 结果中的字段内容在新表中用字段表示,用sql能否实现?
- 向oracle中插入BLOB对象时出现了Io 异常: Connection reset!!!!
- Oracle里not in 有关null处理的奇怪问题,欢迎大家来讨论。
- 求助,什么叫迫切左外连接,迫切内连接。另,oracle中sql语句默认的连接方式。
- 如何才能打开ORACLE的*.DBF文件?---火急!
- 急救!关于OLEDB连ORCLE读IMAGE数据格式问题!
- 请指教!
- sybase数据库导入到Oracle中 代码转换问题
- 数据拼接和加工,200分求解决,在线等
select case when a>50 and a<100 then 1
when a>100 and a<150 then 1.5 ...(后面自己拼就行)end
from tab;
SQL>
SQL> with tab as
2 (
3 select 20 id from dual union all
4 select 120 id from dual union all
5 select 170 id from dual union all
6 select 220 id from dual
7 )
8 select case
9 when mod(id, 100) <= 50 then
10 floor(id / 100) + 0.5
11 else
12 floor(id / 100) + 1
13 end
14 from tab
15 ;CASEWHENMOD(ID,100)<=50THENFLO
------------------------------
0.5
1.5
2
2.5SQL>
已写入 file afiedt.buf 1 create or replace function fun_int(cnt number) return number
2 as
3 v_num number(28,1);
4 res number;
5 begin
6 if cnt>50 then
7 v_num:=cnt/100;
8 if instr(v_num,'.')>0 then
9 select
10 decode(sign(substr(v_num,instr(v_num,'.')+1)-5),1,ceil(v_num),0,ceil(v_num),
11 substr(v_num,1,instr(v_num,'.')-1)+0.5)
12 into res from dual;
13 else
14 res:=v_num;
15 end if;
16 else
17 null;
18 end if;
19 return res;
20* end;
scott@ORCL> /函数已创建。scott@ORCL> ed
已写入 file afiedt.buf 1* select fun_int(52),fun_int(126),fun_int(151),fun_int(200) from dual
scott@ORCL> /FUN_INT(52) FUN_INT(126) FUN_INT(151) FUN_INT(200)
----------- ------------ ------------ ------------
1 1.5 2 2