ltannous
3rd August 2005, 22:50
I have a session script where I am selecting various information, after the first select is complete, i have another select in the same statement. Why is there data in my second select that does not equal the prerequisits from my first select? ( My sum(tdssc051.cqtr) is selecting all the tdssc051.cqtr for the item and not just the ones that meet the first select criteria.
tobld = 0
totalcum = 0
totauth = 0
select tdssc051.*, tccom010.*, tiitm001.*, tdssc050.*, tdssc001.*
from tdssc051, tccom010, tiitm001, tdssc050, tdssc001
where tdssc051._index1 inrange {:cuno.f, :cdel.f, :item.f,
:cont.f, :pono.f}
and {:cuno.t, :cdel.t, :item.t, :cont.t, :pono.t}
and tdssc051.auth = :auth.f
and tdssc051.cuno refers to tccom010
and tdssc051.item refers to tiitm001
and tdssc051.auth refers to tdssc050
and tdssc001.cuno = tdssc051.cuno
and tdssc001.cdel = tdssc051.cdel
and tdssc001.item = tdssc051.item
and tdssc001.cont = tdssc051.cont
and tdssc001.pono = tdssc051.pono
and tdssc001.stat = "LV"
and tdssc001._compnr = :comr
and tdssc051._compnr = :comr
and tdssc050._compnr = :comr
and tccom010._compnr = :comr
and tiitm001._compnr = :comm
order by tdssc051.item
selectdo
select sum(tdssc001.ydeq):totalcum
from tdssc001
where tdssc001.item = :tdssc051.item
and tdssc001.cuno inrange :cuno.f and :cuno.t
and tdssc001.cdel inrange :cdel.f and :cdel.t
and tdssc001.cont inrange :cont.f and :cont.t
and tdssc001.pono inrange :pono.f and :pono.t
and tdssc001.stat = "LV"
and tdssc001._compnr = :tdssc001._compnr
selectdo
select sum(tdssc051.cqtr):totauth
from tdssc051
where tdssc051.item = :tdssc051.item
and tdssc051._compnr = :comr
and tdssc051.cuno inrange :cuno.f and :cuno.t
and tdssc051.cdel inrange :cdel.f and :cdel.t
and tdssc051.cont inrange :cont.f and :cont.t
and tdssc051.pono inrange :pono.f and :pono.t
and tdssc051.auth = :auth.f
selectdo
select sum(tisfc001.qrdr),sum(tisfc001.qdlv)
from tisfc001
where tisfc001.mitm = :tdssc051.item
and tisfc001._compnr = :comm
and tisfc001.osta between tcosta.free and tcosta.hours.adj
selectdo
totbld = tisfc001.qrdr - tisfc001.qdlv
rprt_send()
selectempty
endselect
endselect
endselect
endselect
}
tobld = 0
totalcum = 0
totauth = 0
select tdssc051.*, tccom010.*, tiitm001.*, tdssc050.*, tdssc001.*
from tdssc051, tccom010, tiitm001, tdssc050, tdssc001
where tdssc051._index1 inrange {:cuno.f, :cdel.f, :item.f,
:cont.f, :pono.f}
and {:cuno.t, :cdel.t, :item.t, :cont.t, :pono.t}
and tdssc051.auth = :auth.f
and tdssc051.cuno refers to tccom010
and tdssc051.item refers to tiitm001
and tdssc051.auth refers to tdssc050
and tdssc001.cuno = tdssc051.cuno
and tdssc001.cdel = tdssc051.cdel
and tdssc001.item = tdssc051.item
and tdssc001.cont = tdssc051.cont
and tdssc001.pono = tdssc051.pono
and tdssc001.stat = "LV"
and tdssc001._compnr = :comr
and tdssc051._compnr = :comr
and tdssc050._compnr = :comr
and tccom010._compnr = :comr
and tiitm001._compnr = :comm
order by tdssc051.item
selectdo
select sum(tdssc001.ydeq):totalcum
from tdssc001
where tdssc001.item = :tdssc051.item
and tdssc001.cuno inrange :cuno.f and :cuno.t
and tdssc001.cdel inrange :cdel.f and :cdel.t
and tdssc001.cont inrange :cont.f and :cont.t
and tdssc001.pono inrange :pono.f and :pono.t
and tdssc001.stat = "LV"
and tdssc001._compnr = :tdssc001._compnr
selectdo
select sum(tdssc051.cqtr):totauth
from tdssc051
where tdssc051.item = :tdssc051.item
and tdssc051._compnr = :comr
and tdssc051.cuno inrange :cuno.f and :cuno.t
and tdssc051.cdel inrange :cdel.f and :cdel.t
and tdssc051.cont inrange :cont.f and :cont.t
and tdssc051.pono inrange :pono.f and :pono.t
and tdssc051.auth = :auth.f
selectdo
select sum(tisfc001.qrdr),sum(tisfc001.qdlv)
from tisfc001
where tisfc001.mitm = :tdssc051.item
and tisfc001._compnr = :comm
and tisfc001.osta between tcosta.free and tcosta.hours.adj
selectdo
totbld = tisfc001.qrdr - tisfc001.qdlv
rprt_send()
selectempty
endselect
endselect
endselect
endselect
}