Isaac
Lifelong Learner
- Local time
- Today, 10:46
- Joined
- Mar 14, 2017
- Messages
- 11,108
Say I have a Select list with some correlated subqueries, like:
OutputColumnAlias1 = (select min(somedate) from Table1 t1 where t1.patientid=OuterTableAlias.patientid and t1.labname='labname1')
OutputColumnAlias2 = (select min(somedate) from Table1 t1 where t1.patientid=OuterTableAlias.patientid and t1.labname='labname2')
Is it acceptable to repeat t1 in the second subquery, because it's "scope" will only be limited to the inside of that parenthetical?
Or am I unwittingly producing a bad result because, due to the first subquery, t1 will forever be defined by it's first referenced instance's WHERE clause, (etc) ?
Setting aside the badness of correlated subqueries for a moment, please advise?
PLEASE NOTE THIS IS NOT MICROSOFT ACCESS, THANKS!
OutputColumnAlias1 = (select min(somedate) from Table1 t1 where t1.patientid=OuterTableAlias.patientid and t1.labname='labname1')
OutputColumnAlias2 = (select min(somedate) from Table1 t1 where t1.patientid=OuterTableAlias.patientid and t1.labname='labname2')
Is it acceptable to repeat t1 in the second subquery, because it's "scope" will only be limited to the inside of that parenthetical?
Or am I unwittingly producing a bad result because, due to the first subquery, t1 will forever be defined by it's first referenced instance's WHERE clause, (etc) ?
Setting aside the badness of correlated subqueries for a moment, please advise?
PLEASE NOTE THIS IS NOT MICROSOFT ACCESS, THANKS!