Oracle中如何的decode函数的使用
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/06 16:14:01
Oracle中如何的decode函数的使用
下面是我的一个SQL语句,不用看其他的,就给我看一下decode中的语句,我的意思是当 c.Gsptype的值符合n (17, 18, 19, 21, 22, 101) And Not Between 50 And 99,为b.rgid,否则为0;这个decode语句怎么写?我的是错误的
Select Count(*),
decode (c.Gsptype,In (17, 18, 19, 21, 22, 101) And Not Between 50 And 99, b.rgid,'0') b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And c.Gsptype In (17, 18, 19, 21, 22, 101)
Or c.Gsptype Between 50 And 99
Group By b.rgid
下面是我的一个SQL语句,不用看其他的,就给我看一下decode中的语句,我的意思是当 c.Gsptype的值符合n (17, 18, 19, 21, 22, 101) And Not Between 50 And 99,为b.rgid,否则为0;这个decode语句怎么写?我的是错误的
Select Count(*),
decode (c.Gsptype,In (17, 18, 19, 21, 22, 101) And Not Between 50 And 99, b.rgid,'0') b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And c.Gsptype In (17, 18, 19, 21, 22, 101)
Or c.Gsptype Between 50 And 99
Group By b.rgid
decode中的第二个值应该是一个吧,好像不能使用其他的操作符.
再问: 我觉得也是,那你用case when then 能不能做出来?
再答: 是不是用where条件就能搞定呀,按照条件分两部分,是不是比case更方便点。
Select c.Gsptype, b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And c.Gsptype In (17, 18, 19, 21, 22, 101)
and not c.Gsptype Between 50 And 99
union c.Gsptype, b.rgid,'0'
Select c.Gsptype, b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And ( c.Gsptype not In (17, 18, 19, 21, 22, 101)
or c.Gsptype Between 50 And 99 )
再问: 我觉得也是,那你用case when then 能不能做出来?
再答: 是不是用where条件就能搞定呀,按照条件分两部分,是不是比case更方便点。
Select c.Gsptype, b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And c.Gsptype In (17, 18, 19, 21, 22, 101)
and not c.Gsptype Between 50 And 99
union c.Gsptype, b.rgid,'0'
Select c.Gsptype, b.rgid
From Bms_St_Rg_Dtl b, Pub_Goods c
Where b.Goodsid = c.Goodsid
And ( c.Gsptype not In (17, 18, 19, 21, 22, 101)
or c.Gsptype Between 50 And 99 )
Oracle中如何的decode函数的使用
oracle中decode函数的应用问题.
请教一个oracle decode函数的问题,
oracle中decode的用法,详细介绍下么,
oracle里decode函数问题
PLSQL Developer 中decode()函数的基本用法?
oracle 中 substr函数的问题
Oracle的substr()函数
oracle stddev()和variance()函数的用法,在什么时候使用?
oracle高手进为什么这样差不出值来,数据库中是有值的select wm_concat(decode(a,'01','
oracle PARTITION BY 的使用
decode函数中嵌套了nvl函数,请问怎么用的,比如decode(nvl(a,0),1,2,3),谁给解释下,别跟我说