欢迎您访问52IJ教育培训网,今天小编为你分享的师说方面的学习知识是通过网络精心收集整理的:“casewhen_...sum(case when a.city_id in (47,45,35,37,36) th...”,注意:所整理内容不代表本站观点,如你有补充或疑问请在正文下方的评论处发表。下面是详细内容。
举个例子:比如
a中 当a.city_id in (34, 33, 32) 返回的是1
b中 当a.city_id in (34, 33, 32) 时,是返回的2 你这又是个sum()函数.当然结果不一样了.
其他类似问题
问题1:求救oracle case when用法我现在一张表stuinfo(sid ,sname)结构如下1 ,null2 ,张三现在我想要用以个语句查询出下表的结果1,用户名为空2,张三我这样写不对 设能告诉我那错了帮忙修正过来select case w
1、不用CASE,用NVL函数即可:
SELECT sid,NVL(sname,'姓名为空' ) from stuinfo;
2、CASE:
SELECT sid,
CASE WHEN snameIS NULL THEN '姓名为空' ELSE sname END CASE
from stuinfo;
问题2:oracle 关于 case when order by case when paiming is null then 99 else paiming end asc 这句话有什么问题 else 等于自己这样写是不是有问题 改怎么写[数学科目]
只有paiming 是数字类型的,这个语句是没有问题的.
你这么写有什么错误了吗?
或者直接:
order by nvl(paiming,99)
问题3:mysql的case when语句转oraclewhere子句条件如下:where a.xxx = 'asdf' and (case when (b.i like '%0%') then truewhen (b.i like '%1%') then c.creatorCode = #code#when (b.i like '%2%') then (d.createDept = #dept# and #flag# = 1)else false end)[数学科目]
oracle也有case when的语法,照办就行,不过用在where条件中,需要有返回值的比较.
这是根据你提供的语句修改,给你提供一个参考吧:
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then true
when (b.i like '%1%') and c.creatorCode = #code# then true
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then true
else false
end) = true
这是按照我的业务理解写的
where a.xxx = 'asdf' and (
case
when (b.i like '%0%') then 1
when (b.i like '%1%') and c.creatorCode = #code# then 2
when (b.i like '%2%') and (d.createDept = #dept# and #flag# = 1) then 3
else 4
end) = 1 -- (根据反回结果来过滤数据)
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
