• The error is pretty straight forward:

    you need to add a group by clause.

    DECLARE @Amount MONEY;

    DECLARE @totAmn MONEY;

    SELECT ISNULL(SUM(p.price*s.quantity)+ s.shippingcost,0)

    FROMtbl_shoppingcarts

    INNER JOINtbl_productp ON s.productid =p.productid

    WHERE s.cartid =@cartid

    GROUP BY s.shippingcost;

    Try to format your code. The person who has to read your code will be grateful.

    You can also alias your tables, which makes your query more readable.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP