同样一条sql,在command window中能查出数据,sql window却查不出

zhou_1zhou 2014-07-17 04:19:32
select *
from (select c.unit_name,c.ash,s.tons zrjh,js.jtons jrjh,w.sumpc zrjo,w.smnet zrl,w1.smnet bylj,w2.smnet bnlj
from (select w1.unit_th,w1.s_type,w1.unit_th||w1.s_type un,sum(w1.net) smnet,sum(w1.price* w1.net) sumpc
from t_weight_info w1
where w1.weigh_date = '2014-07-03' and w1.s_type in('II级灰','III级灰','粗灰')
group by w1.unit_th,w1.s_type) w,
(select w1.unit_th,w1.s_type,w1.unit_th||w1.s_type un,sum(w1.net) smnet,sum(w1.price* w1.net) sumpc
from t_weight_info w1
where w1.weigh_date between '2014-07-01' and '2014-07-03' and w1.s_type in('II级灰','III级灰','粗灰')
group by w1.unit_th,w1.s_type) w1,
(select w1.unit_th,w1.s_type,w1.unit_th||w1.s_type un,sum(w1.net) smnet,sum(w1.price* w1.net) sumpc
from t_weight_info w1
where w1.weigh_date between '2014-01-01' and '2014-07-03' and w1.s_type in('II级灰','III级灰','粗灰')
group by w1.unit_th,w1.s_type) w2,
(select s1.unit_name,s1.s_type,s1.unit_name||s1.s_type un,s1.tons
from t_sale_plan s1
where s1.p_stime between '2014-07-02' and '2014-07-03' and s1.s_type in('II级灰','III级灰','粗灰')) s,
(select s2.unit_name,s2.s_type,s2.unit_name||s2.s_type un,s2.tons jtons
from t_sale_plan s2
where s2.p_stime between '2014-07-03' and '2014-07-04' and s2.s_type in('II级灰','III级灰','粗灰')) js,
(select tc.unit_name,ta.ash,tc.unit_name||ta.ash un from t_client_info tc,t_ash_info ta where ta.ash in('II级灰','III级灰','粗灰')) c
where c.un = w.un(+)
and c.un = s.un(+)
and c.un = w1.un(+)
and c.un = w2.un(+)
and c.un = js.un(+)) ws
where ws.zrl is not null or ws.jrjh is not null or ws.zrjh is not null
or ws.unit_name in (select w1.unit_th from t_weight_info w1 where w1.weigh_date = '2014-07-03' and w1.s_type in('II级灰','III级灰','粗灰'))
or ws.unit_name in (select s1.unit_name from t_sale_plan s1 where s1.p_stime between '2014-07-02' and '2014-07-03' and s1.s_type in('II级灰','III级灰','粗灰'))
...全文
228 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ghost_520 2014-07-17
  • 打赏
  • 举报
回复
把报错信息帖出来啊 把每个 or 条件用括号包起来试试 where (ws.zrl is not null )or ws.jrjh is not null or ws.zrjh is not null or ws.unit_name in (select w1.unit_th from t_weight_info w1 where w1.weigh_date = '2014-07-03' and w1.s_type in('II级灰','III级灰','粗灰')) or ws.unit_name in (select s1.unit_name from t_sale_plan s1 where s1.p_stime between '2014-07-02' and '2014-07-03' and s1.s_type in('II级灰','III级灰','粗灰'))
卖水果的net 2014-07-17
  • 打赏
  • 举报
回复
1. LZ 你确认一下,连的库是不是同一个。 2. SQL 窗口,你转轮子了吗?(如果你使用的是 PL\SQL Developer 的话)。
  • 打赏
  • 举报
回复
楼主这问题很特别,未发现问题出在哪,按理不应该出现。 楼主sql有一点不好的地方,笛卡尔积。 (select tc.unit_name, ta.ash, tc.unit_name || ta.ash un from t_client_info tc, t_ash_info ta where ta.ash in ('II级灰', 'III级灰', '粗灰')) c

17,140

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧