if exists(select * from tablename where colum4<>'0')
select * from tablename where colum4='0'
else
select *from tablename where '1'='2'
不知道理解是否正确!
select * from tablename where colum4='0'
else
select *from tablename where '1'='2'
不知道理解是否正确!
解决方案 »
- mssql存储转成ORACLE
- 4G内存安装Oracle 11g 可以不设交换区吗?
- 入门,数据库恢复问题
- 请大家帮忙看一个问题:为什么存储过程执行如此不稳定呢?
- Linux下Oracle字符集问题引发的汉字插入失败解决方案
- 关于默认值问题!十万火急,在线等待!
- 如何用sql查询出某个月的第一天,和最后一天
- 网上介绍JSP和ORACLE连接的文章很多,但都没说到在ORCALE一端该如何配置,可我真的很想知道!!
- 在redhat7.2下内核不同对oracle8i有什么影响?LD_ASSUME_KERNEL设置不同,为什么会产生不同结果
- Oracle 触发器,个人对触发器不怎么熟悉,希望能写明白点,谢谢
- ORA-08103: object no longer exists 什么情况下会发生?
- 各位大侠看看这个触发器怎么写?
如何查找一个表中部分相同的记录,如果部分相同的记录不存在,则查找出来!!! 而且colume4的值不确定的啊,我只是列个例子出来
a.*
from
tablename a
where
not exists(select 1 from tablename where col1=a.col1 or col2=a.col2 or col3=a.col3 or col4=a.col4)
(select b.fld1,b.fld2,b.fld3 from tablename b
group by b.fld1,b.fld2,b.fld3
having count(*) = 1) c
where a.fld1 = c.fld1
and a.fld2 = c.fld2
and a.fld3 = c.fld3
--把tablename和fld1/2/3 替换成目标表和对应的字段
http://community.csdn.net/Expert/topic/3810/3810928.xml?temp=.1188166
执行:
select distinct a1.a,a2.b,a3.c,a4.d
from a a1,a a2,a a3,a a4
where a1.a=a2.a
and a1.a=a3.a
and a1.a=a4.a
and a1.b=a2.b
and a1.b=a3.b
and a1.b=a4.b
and a1.c=a2.c
and a1.c=a3.c
and a1.c=a4.c
and a1.d=0
and a2.d=0
and a3.d=0
and a4.d=0;
结果:
A B C D
---------- ---------- ---------- ----------
a b b 0
a b c 0
b b c 0