select
(
select operprice_0 from
(
select t.operprice_0 from
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=abc.depotid
and t.mlid=abc.mlid
order by t.bloperdate desc
) where rownum=1
) as b
from sto_v_storagebak abc
where
abc.depotid=1718 and abc.mlid=19372
and abc.bakyear=2009 and abc.bakmonth=07
用上面语句查询时,b的值为0
改为下面查时
select
(
select operprice_0 from
(
select t.operprice_0 from
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=1718
and t.mlid=19372
order by t.bloperdate desc
) where rownum=1
) as b
from sto_v_storagebak abc
where
abc.depotid=1718 and abc.mlid=19372
and abc.bakyear=2009 and abc.bakmonth=07
出来的是具体的值其实出来的就是具体的值,但是不知道为什么用第一种查出来的一直是0,想不明白呀,望高手指点.
(
select operprice_0 from
(
select t.operprice_0 from
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=abc.depotid
and t.mlid=abc.mlid
order by t.bloperdate desc
) where rownum=1
) as b
from sto_v_storagebak abc
where
abc.depotid=1718 and abc.mlid=19372
and abc.bakyear=2009 and abc.bakmonth=07
用上面语句查询时,b的值为0
改为下面查时
select
(
select operprice_0 from
(
select t.operprice_0 from
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=1718
and t.mlid=19372
order by t.bloperdate desc
) where rownum=1
) as b
from sto_v_storagebak abc
where
abc.depotid=1718 and abc.mlid=19372
and abc.bakyear=2009 and abc.bakmonth=07
出来的是具体的值其实出来的就是具体的值,但是不知道为什么用第一种查出来的一直是0,想不明白呀,望高手指点.
解决方案 »
- 命令的问题
- 如何写个循环SQL语句?
- 关于oracle 10g 不想显示部分数据的问题
- 菜鸟求助oracle的简单查询语句
- 请问有人能解释这个SQL文问题吗?可能要对数据库工作原理做一下解释,明白的大虾进
- PL/SQL developer command窗口 中表各列的对齐问题
- 火起!一声怒吼!我们程序员就不是人吗?
- 请教一个关于更新的问题
- 给出了一个字段的名字,如何知道该字段来自库中哪个表,包括判断是否有该表?(用PB)
- 如何实现当两张表拥有共同的字段时,将两张表相应内容插入第三张表?
- 急急急!Oracle forms 的Text Item 的属性如何设置成只能入力半角英数
- 大牛門看一看是否正確!
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=abc.depotid
and t.mlid=abc.mlid
order by t.bloperdate desc
) where rownum=1
select t.operprice_0 from
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t
where
t.depotid=1718
and t.mlid=19372
order by t.bloperdate desc
) where rownum=1
这两个查询出来应该不一样
std.operprice_0没有为0的值吗?
(
select stb.bloperdate,stb.depotid,std.mlid,std.operprice_0
from sto_t_blmaster stb,sto_t_bldetail std,sto_t_blsort sts
where stb.id=std.masterid
and stb.blsortid=sts.id
and sts.belongto='01'
and stb.staoper='2'
) t ,sto_v_storagebak abc
where
t.depotid=abc.depotid
and t.mlid=abc.mlid
order by t.bloperdate desc
运行这个看看
where
t.depotid=abc.depotid
and t.mlid=abc.mlid
order by t.bloperdate desc
这里面完全等于连接的时候 有不匹配的。有那个ID对应不上。
t.depotid=abc.depotidand t.mlid=abc.mlid
这里取不到abc.mlid的值。