oracle数据库中可以用 if exists 吗,我用为什么报错?如果可以用,请举个例子。
答案:3 悬赏:30
解决时间 2021-01-23 17:01
- 提问者网友:临风不自傲
- 2021-01-22 23:51
oracle数据库中可以用 if exists 吗,我用为什么报错?如果可以用,请举个例子。
最佳答案
- 二级知识专家网友:舊物识亽
- 2021-01-23 00:58
抱歉你误解了oracle数据库中没有if exists。
具体解释和案例在http://blog.csdn.net/hollboy/article/details/7550171
自己看看。
具体解释和案例在http://blog.csdn.net/hollboy/article/details/7550171
自己看看。
全部回答
- 1楼网友:山君与见山
- 2021-01-23 03:15
if exists 是sqlserver的专有的,oracle没有
相应的办法:
简单sql中有
case when
pl/sql 中有
if... then
相应的办法:
简单sql中有
case when
pl/sql 中有
if... then
- 2楼网友:想偏头吻你
- 2021-01-23 02:02
不知道 你具体的是什么意思。
一般用case when 或者 where exists ~不要用汉语的思维模式~~~
参考sql:
create table tmp_wss_2012493_2 as
select
t1.serv_number,
count(distinct case when t1.charge_type <> '7' then t1.serv_number else null end) fee_use_num, --举例
from cdmp_dw.td_aaa_bill_d t1
where t1.statis_day between '20121101' and '20121130'
and exists(select '1' from xxxx t2 where t2.serv_number=t1.sev_number)---举例
group by t1.serv_number;
如果写procedure 也是这种思想~~~单纯的if exists 我是没见过~~~你想表达如果存在么?
case when 不可以么
一般用case when 或者 where exists ~不要用汉语的思维模式~~~
参考sql:
create table tmp_wss_2012493_2 as
select
t1.serv_number,
count(distinct case when t1.charge_type <> '7' then t1.serv_number else null end) fee_use_num, --举例
from cdmp_dw.td_aaa_bill_d t1
where t1.statis_day between '20121101' and '20121130'
and exists(select '1' from xxxx t2 where t2.serv_number=t1.sev_number)---举例
group by t1.serv_number;
如果写procedure 也是这种思想~~~单纯的if exists 我是没见过~~~你想表达如果存在么?
case when 不可以么
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯