11:50:08 SQL> select * from t1; A B
---------- ----------
1 1
1 2
2 3
2 4
3 4已用时间: 00: 00: 00.00
11:50:21 SQL> select case when a=b then 999 else a+b end from t1;CASEWHENA=BTHEN999ELSEA+BEND
----------------------------
999
3
5
6
7已用时间: 00: 00: 00.16
---------- ----------
1 1
1 2
2 3
2 4
3 4已用时间: 00: 00: 00.00
11:50:21 SQL> select case when a=b then 999 else a+b end from t1;CASEWHENA=BTHEN999ELSEA+BEND
----------------------------
999
3
5
6
7已用时间: 00: 00: 00.16
解决方案 »
- oracle 分组统计的问题 ... 求解 .
- 连接不上本机数据库
- oracle导出请教,在线等
- Update 序号问题
- 按指定id顺序输出,例如id为(3,12,8,9,45,6),要求查询结果也按照这个顺序输出。这个id是已知的。请高手指定,多谢!!
- 按部门合计SAL值?
- 各位大虾 下面的这两个函数错在哪了,兄弟我跪求答案了
- 用exp/imp导入数据,表数据没有问题,但存储过程汉字都变成乱码了,怎么回事?
- oracle的安裝
- oracle数据库在官网下载只下载了file1文件 导致数据库没有scott用户
- 紧急求助各路ORACLE大侠,启动过程的ORA-01031的问题,多谢
- 请教一个初级问题。急。。。。。。。。。在线等待
select case when a=b then 999 else a+b end from t1;decode的写法:
select decode(a,b,999,a+b) from t1
请参考:
Examples
This example decodes the value warehouse_id. If warehouse_id is 1, then the
function returns ’Southlake’; if warehouse_id is 2, then it returns ’San
Francisco’; and so forth. If warehouse_id is not 1, 2, 3, or 4, then the function
returns ’Non-domestic’.
SELECT product_id,
DECODE (warehouse_id, 1, ’Southlake’,
2, ’San Francisco’,
3, ’New Jersey’,
4, ’Seattle’,
’Non-domestic’)
quantity_on_hand FROM inventories;