Ok,many thanks
but what I´m trying to do is something more complex...
Select aa, bb, 'Neto Gravado'= sum(case when tligfact.ligfaccalculcode
in ('5701','5702','5703','5704','5705','5706','5707','5708','5709','5710','5711','5712','5713','171','172','12','16','28','180','5608','7709') then 0
else (tligfact.ligfacunitprice*tligfact.ligfacqtefac) end)
from tligfact where ......
If I put a subquery inside the IN, I get an error, it saids that I cannot put a subquery inside an agregate function !!!, seems to belong from the SUM() ?
So I think that a good idea is to put the result of this subq into a variable. But does not work.
Ive tried Frank´s , but I get this "Cannot convert parameter '@statement' to ntext/nchar/nvarchar data type expected by procedure. " and now I dont know how to jump this.
waiting for any other idea..........