oracle case when与decode语句

本文介绍了Oracle数据库中casewhen语句及decode函数的应用场景。通过具体示例展示了如何利用这两种方法进行条件判断,特别是在盘点盈亏和员工信息查询等场景中的应用。
今天遇到sql语句中要判断不知道怎么做,于是找了一下,哈哈oracle挺强的
先看case when 语句:
select case when c.store_amount-c.amount > 0 then '盘盈'
when c.store_amount-c.amount < 0 then '盘亏'
else '持平' end from sghis.pa_pham_check_detail c'
decode语句:
select t.employee_id,
t.employee_name,
decode(t.sex , '1' , '男', '2' , '女', ' ') as sex,
t.age,
a.office_name,
t.office_code,
b.dmmc || ' ' as work_p,
t.work_position,
t.doctor_code || ' ' as doctor_code,
e.dmmc,
t.technic_title,
t.py_code,
t.wb_code
from sghis.hd_employee t,
sghis.hd_office_dict a,
(select c.dmsb, c.dmmc
from sghis.hd_gy_dmzd c
where c.dmlb = '7'
and c.xtsb = '0') b,
(select d.dmsb, d.dmmc
from sghis.hd_gy_dmzd d
where d.dmlb = '8'
and d.xtsb = '0') e
where t.office_code = a.office_code
and t.work_position = b.dmsb(+)
and t.technic_title = e.dmsb(+)
and t.hos_id = '$P!{hos_id}'
and t.employee_name like '%$P!{employee_name}%'
and t.office_code like '%$P!{office_code}%'
and t.py_code like '%$P!{py_code}%'
and t.wb_code like '%$P!{wb_code}%'
order by t.office_code
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值