当前位置:数据库 > Oracle >>

oracle数据裤表,怎么才能过滤掉我不想要的数据啊?

已经查询出我想要的数据后,但我发现有的数据是正确的,需要过滤掉,请问过滤条件和语句怎么写,注,前面已经有语句了,怎么把过滤条件加进去。如下: select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1) 就是不能把上面语句的意思改掉,然后把需要过滤掉的参数设置进去,然后符合参数值的不需要显示,不知道意思表达明白没?请高手教导下,谢谢了 怎么才能加在语句上,并不改变意思
追问:select * from (
select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1)
)where 数据项3='满足条件' and 数据项4='满足条件' not is null
请问老师,我的意思就是在select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1)查询中出来的数据再进行筛选,这些数据中,条件满足数据项3,4的,就不显示了,请老师指点,谢谢
答案:你上面语句的意思似乎想查       表中数据项2重复数据中又都满足数据项1 和数据项2的记录。
不太明白你要那些数据。到底是保留这些重复数据中满足条件1和2的,还是不保留。
如:select * from a  where 1  and 2 in(select  2  from b  group by 2 having count(*)>1)
我写的语句的意思是:在b表中2字段重复数据的2字段和a表中1条件 同时满足的a表中的记录。
其他:把你这个语句当成子查询。 例如 select * from (
select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1)

)where xxxxx 
明白了么 select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1)
在这个语句后直接加: and 你的过滤条件啊~
比如:
select * from 表 where 数据项1 and 数据项2 In(select mc from 表 group by 数据项2 Having Count(*)>1)  and 数据项3  is not null 不显示就用 not in (条件)
      不明白你说的不能改语句的意思是 什么意思。你不改条件怎么行 

上一个:在oracle中select * from v$pwfile_users为什么回复是2
下一个:oracle 中类似tb_bil_acct_%ld查询语句里带%ld的是什么用法 求指点!

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,