• Here is a quick method. NOT recommended for speed or flexibility ... If you would outline your requirements in greater detail perhaps some one can / will give you further assistance.

    CREATE TABLE For_Test(ID int not null,Name varchar(255),Amount decimal(18,2))

    INSERT INTO For_Test VALUES (1,'A',220),(2,'B',340),(3,'C',540)

    ,(4,'D',780)

    --I just want to add amount of ID 1,2 and 3 excluding 4.

    SELECT SUM(Amount) FROM For_Test WHERE ID in (1,2,3)

    --Different select statement but same result

    SELECT SUM(Amount) FROM For_Test WHERE ID <> 4

    --Yet a 3rd way

    SELECT SUM(Amount) FROM For_Test WHERE ID < 4

    --Yet a 4th way - using MOD function

    SELECT SUM(Amount) FROM For_Test WHERE ID % 4 <> 0;

    Result:

    (No column name)

    1100.00

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]