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

oracle 相干子查询

2012-08-11 
oracle 相关子查询select sum(t1.sales) from Store_information t1where t1.store_nameIN (Select Store_

oracle 相关子查询
select sum(t1.sales) from Store_information t1 
  where t1.store_name 
  IN (Select Store_name from Geography t2 where t2.store_name = t1.store_name)



以上sql文一运行就报错,有没有高手给解答一下是什么原因?

[解决办法]
你难道没看出来你的条件矛盾了吗?
不知道你的需求,猜测一下。

SQL code
select sum(t1.sales) from Store_information t1,Geography t2   where t1.store_name = t2.store_name;
[解决办法]
select sum(t1.sales) from Store_information t1
where t1.store_name
IN (Select Store_name from Geography t2 ,Store_information t1 where t2.store_name = t1.store_name)

[解决办法]
LZ贴下错误吧,表示没看出来错误在哪。
SQL code
select sum(t.operid) from operskill t where t.skillid in (     select skillid from skillinfo t1 where t.skillid =t1.skillid);
[解决办法]
SQL code
--別用in,效率低select sum(t1.sales) from Store_information t1    where exists (Select 1 from Geography t2 where t2.store_name = t1.store_name); 

热点排行