首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

请问最为优化的查询语句

2011-12-27 
请教最为优化的查询语句。在oracle8i中有一表记载了销售记录,现在想查询某个日期以后没有再销售的客户记录

请教最为优化的查询语句。
在oracle8i中有一表记载了销售记录,现在想查询某个日期以后没有再销售的客户记录请教有最优化的语句吗?
表:xs   :khid(客户khid)     、   xsrq(销售日期)等其他销售信息大概有800多万条记录,用以下语句搜索时间很长请教有更好的语句吗?

  select   *   from   xs   a   where   khid
        not   in
(select   DISTINCT   kuid   from   jyz_xs   where   khid=a.kuid   xsrq> '2007/03/05 '   )


[解决办法]
select * from xs a
where not exists
(select DISTINCT khid from xs where khid=a.khid and xsrq> '2007/03/05 ' )
---或者
select a.* from xs a,(select * from xs) b
where a.khid(+)=b.khid and b.xsrq> '2007/03/05 '
and a.khid is null)

不知道哪种更好,或者有其他方法
试试吧
[解决办法]
select * from xs a
where not exists
(select null from xs where khid=a.khid and xsrq> '2007/03/05 ' )

热点排行
Bad Request.