oracle查询语句条件判断怎么写

一个表中有数据idstatename10jack11li20zh查询语句要怎么写,能够判断条件,同一个id,当状态state有1时查询1的这条,state没有1时查询0这... 一个表中有数据
id state name
1 0 jack
1 1 li
2 0 zh
查询语句要怎么写,能够判断条件,同一个id,当状态state有1时查询1的这条,state没有1时查询0这条
查询结果如下
1 1 li
2 0 zh
展开
 我来答
千锋教育
2016-01-14 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
展开全部

一个多条件判断的sql:

select 
        oper.opid,
        oper.user_name,
        oper.user_host,
        case 
        when oper.oper_type = 1  then 'System Manager' 
        when oper.oper_type = 2  then 'USER Manager'
        end case,
        case
        when oper.oper_object_type = 1 then 'User'
        when oper.oper_object_type = 2 then 'Role'
        when oper.oper_object_type = 3 then 'Broker'
        when oper.oper_object_type = 4 then 'QM Manager'
        when oper.oper_object_type = 5 then 'User Group'
        when oper.oper_object_type = 6 then 'Msg Flow'
        when oper.oper_object_type = 7 then 'Queue'
        end case
     
 from esb_log_user_oper oper;
tj_angela
2015-01-12 · TA获得超过7531个赞
知道大有可为答主
回答量:6797
采纳率:75%
帮助的人:2723万
展开全部
select id,state,name
from (select id,state,name,row_number() over(partition by id order by state desc) rn
from table_name)
where rn<=1;
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式