Multiple level nested Corelated query
- From: "Zero.NULL" <manish19@xxxxxxxxx>
- Date: 30 Sep 2005 04:11:34 -0700
My multiple level nested corelated query is not fetching correct
result. It work fine on small set of data, but fails on larger set of
data. Any clue?
Explaining data storing and discussing design would be tough for me
here, still to show you how complex I have created my life, here is the
query:
select
(
SELECT Top 1 RowNSBranchID FROM AssoExtBranchToNSBranchMstM AM
-- MMM
WHERE AM.RowExtSysID IN
(
SELECT RowID FROM ExternalSystemMstM WHERE ExtSysID =
(
SELECT ExtSysID FROM ExternalSystemMstM WHERE SF = 'Active' AND
RowID =
(
SELECT MAX(RowID) FROM ExternalSystemMstM WHERE MCStatus = 2 AND
ExtSysCode = UM.SystemCode
)
)
)
AND RowExtBranchID IN
(
SELECT RowID FROM ExternalBranchMstM
WHERE ExtBranchID =
(
SELECT ExtBranchID FROM ExternalBranchMstM
WHERE ROWID =
(
SELECT RowID FROM ExternalBranchMstM
WHERE ROWID =
(
SELECT MAX(ROWID) FROM ExternalBranchMstM WHERE MCStatus = 2 AND
ExtBranchCode = UM.UpBranchCode
AND RowExtSysID IN
(
SELECT RowID FROM ExternalSystemMstM WHERE ExtSysID =
(
SELECT ExtSysID FROM ExternalSystemMstM WHERE SF = 'Active' AND
RowID =
(
SELECT MAX(RowID) FROM ExternalSystemMstM WHERE MCStatus = 2
AND ExtSysCode = UM.SystemCode
)
)
)
)
AND (SF = 'Active')
)
)
)
AND AM.SF = 'Active'
order by AssoID desc,TrackID desc
) nsbranchid, UM.*
from
TmpInProcessData062005MstM UM
.
- Follow-Ups:
- Re: Multiple level nested Corelated query
- From: Hugo Kornelis
- Re: Multiple level nested Corelated query
- Prev by Date: Problem with case expression
- Next by Date: Can't "SELECT" using CREATED_DATE column...help
- Previous by thread: Problem with case expression
- Next by thread: Re: Multiple level nested Corelated query
- Index(es):