Assuming @a will always be a positive number you can change
where ((avg_cost - std_cost)*in_stock >= @a
or (avg_cost - std_cost)*in_stock <= -1* @a)
to
where (ABS((avg_cost - std_cost)*in_stock) >= @a)
Lutz
A pessimist is an optimist with experience. How to get fast answers to your question[/url]
How to post performance related questions[/url]
Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]