请教一个select语句的条件写法 本帖最后由 binsea1 于 2012-06-14 13:07:19 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 id det flag10011 1 null10021 null null1003A 2 A1003B 3 null1004A null A这样一个表,选出det不为空的,如果id末尾为A或B并且flag不为空的也选上,结果如下: id det flag10011 1 null1003A 2 A where det is not null or (substr(id,-1) in ('A','B') and flag is not null) 楼上的这个条件我用了,结果会是:id det flag10011 1 null1003A 2 A1004A null A where det is not null where det is not null and((substr(id,-1) in ('A','B') and flag is not null )or substr(id,-1) not in ('A','B')) where det is not null and((substr(id,-1) in ('A','B') and flag is not null )or substr(id,-1) not in ('A','B')) 7楼,果然不错哦。我对这种or and 搭配很头痛 存储过程调用返回游标获取不到 高手帮忙! ORACLE 存储过程返回记录的问题? 触发器的问题不知道那里 出错 我准备把数据库改为归档模式,在shutdown时老是出现“ORA-00106: 无法在连接到调度程序时启动/关闭数据库”,应该怎样处理?? 不能连接到事务管理器或事务管理器不可用 使用oracle数据库,提示连接未打开错误,请大家帮忙,谢谢 如何使计数器(序列)自动重置?? 请教关于ORACLE表锁定的问题!谢谢 百分求解高效SQL文! 还是sql语句不会写 【求助】求一个存储过程 分析函数排序问题求教
10011 1 null
10021 null null
1003A 2 A
1003B 3 null
1004A null A
这样一个表,选出det不为空的,如果id末尾为A或B并且flag不为空的也选上,结果如下:
id det flag
10011 1 null
1003A 2 A
10011 1 null
1003A 2 A
1004A null A
where det is not null and((substr(id,-1) in ('A','B') and flag is not null )or substr(id,-1) not in ('A','B'))
and((substr(id,-1) in ('A','B') and flag is not null )or substr(id,-1) not in ('A','B'))
我对这种or and 搭配很头痛