Hey guys
I have a current query that looks something like:
select a.avalue, b.bvalue, c.cvalue from
(select idVal, dummyVal as avalue from....) as a
left join
(select idVal, dummyVal as bvalue from....) as b
on a.idVal = b.idVal
left join
(select idVal, dummyVal as cvalue from....) as c
on b.idVal = c.idVal
Now, in each of those nested select statements, I need to put another nested select, so i have something like:
select a.avalue, b.bvalue, c.cvalue from
(select idVal, dummyVal as avalue from (select ...)) as a
left join
(select idVal, dummyVal as bvalue from (select ...)) as b
on a.idVal = b.idVal
left join
(select idVal, dummyVal as cvalue from (select ...)) as c
on b.idVal = c.idVal
Now, because my actual query is a lot bigger and complex than the one above, it will take a long time to execute. So i was wondering if i were to create the new nested select statement from the second code example separately, and then left join the 3 queries to it, would it run any faster? I haven't tried yet as my query is very bug and want to ask aroundhere for opinions first. I'm thinking something like
select a.avalue, b.bvalue, c.cvalue from
//new nested query
(select idVal as nestedvalue from ...) as nested
left join
(select idVal, dummyVal as avalue from ...) as a
on a.idVal = nested.idVal
left join
(select idVal, dummyVal as bvalue from ...) as b
on b.idVal = nested.idVal
left join
(select idVal, dummyVal as cvalue from ...) as c
on c.idVal = nested.idVal
Any help is greatly appreciated!