select createdate from cp_projectplan where not exists ( select createdate from cp_projectplan where createdate < to_date('2010-09-02','yyyy-mm-dd')
or createdate > to_date('2010-09-04','yyyy-mm-dd') )明明有9月3号创建的数据,为什么结果是空的
or createdate > to_date('2010-09-04','yyyy-mm-dd') )明明有9月3号创建的数据,为什么结果是空的
select createdate from cp_projectplan where createdate between to_date('2010-09-02','yyyy-mm-dd')
and createdate > to_date('2010-09-04','yyyy-mm-dd')
select createdate from cp_projectplan where createdate between to_date('2010-09-02','yyyy-mm-dd')
and to_date('2010-09-04','yyyy-mm-dd')
where createdate between to_date('2010-09-02','yyyy-mm-dd') and createdate > to_date('2010-09-04','yyyy-mm-dd') )
把你的数据贴些出来看看
and createdate > to_date('2010-09-04','yyyy-mm-dd')
我如果一定要用not exists 加 子查询 应该怎么写 我问这题 主要是为了搞明白not exists的用法
我如果一定要用not exists 加 子查询 应该怎么写 我问这题 主要是为了搞明白not exists的用法
--查询各部门中工资最的人
select * from emp t
where not exists(
select 1 from emp where deptno=t.deptno
and sal>t.sal)
select createdate from cp_projectplan a
where not exists (
select createdate from cp_projectplan b where a.createdate=b.createdate
and (b.createdate < to_date('2010-09-02 23:59:59','yyyy-mm-dd hh24:mi:ss') or b.createdate > to_date('2010-09-04','yyyy-mm-dd'))
)--为什么不直接下面的,搞这么复杂
select createdate from cp_projectplan where to_char(createdate,'yyyy-mm-dd')='2010-09-03'
试下下面这句:
select createdate from cp_projectplan t where not exists
( select createdate from cp_projectplan
where t.createdate <= to_date('2010-09-02','yyyy-mm-dd')
or t.createdate >= to_date('2010-09-04','yyyy-mm-dd') )
select createdate from cp_projectplan t where trunc(t.createdate)='3-sep-2010';
这个肯定能出来结果,LZ自己后面改成子查询吧.
and to_date('2010-09-04','yyyy-mm-dd')