|
Note: I originally asked this yesterday on StackOverflow. However, the high-turnover of questions means there is little chance of getting a satisfactory answer. I have this
If you plug in the
How do you use the outer clause on an inner statement? Hell, I don't even know if I am using the correct terminology to describe my problem. Arrgghh - Set based logic does my head in!!
(comments are locked)
|
|
How about something like this instead? That gives a 'Column 'sumMD.SumMDQuantity' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.' error but gives me a clue on how to advance.
Oct 20 '09 at 05:40 AM
graham.reeds
Add sumMD.SumMDQuantity to the Group By line and it works.
Oct 20 '09 at 06:11 AM
graham.reeds
Implemented this way it takes 2m 40s. However implemented the way I was originally trying takes 2m 11s for the same db and range.
Oct 20 '09 at 07:02 AM
graham.reeds
But the way you were originally doing this didn't manage to join to every siteid as you couldn't get the @x join working.
Oct 20 '09 at 07:39 AM
RickD
But the clue was the renaming of the outer MasterDates as MD - which enabled me to use MD.SiteID = MasterDates.SiteID in the WHERE clause.
Oct 20 '09 at 07:50 AM
graham.reeds
(comments are locked)
|
(comments are locked)
|

