Krishna1 (6/25/2013)
Dear AllI have folloing query
select sum(yy) sumyy, 'summary line' xx
from tablea
where somedate_column < @startdate_parameter
union
select yy, xx
from tablea
where somedate_column between @startdate_parameter and @enddate_parameter
Is there a better way to achive this or this is the ok
Regards
Krishana
I agree with what Sean Lange said. The only thing that you can do, which isn't much, is to change the BETWEEN condition in the second part of the UNION to be:
WHERE somedate_column >= @startdate_parameter and somedate_column <= @enddate_parameter
This is what the optimizer does in the background anyway, so save it the need to do so.