SQL Server Performance

HOW TO ADD A COLUMN VALUE

Discussion in 'ALL SQL SERVER QUESTIONS' started by immad, Dec 30, 2014.

  1. immad Member

    HI,
    I have a problem.
    my data is look like this.

    EvS_VoucherCode--------Name----TotalAmount
    ACT----------------------------1------------------3
    ACT----------------------------1------------------3
    DEF----------------------------2------------------4
    DEF----------------------------2------------------4
    DEF----------------------------2------------------4

    i want data looks like this.

    EvS_VoucherCode--------Name---------TotalAmount
    ACT-------------------------------2-----------------6
    DEF-------------------------------6------------------12

    please help me out.
    thanks for the help.
  2. mkal New Member

    Assuming your column data type for Name and TotalAmount are int this should work.

    SELECT EvS_VoucherCode, SUM(name) AS name, SUM(TotalAmount) AS TotalAmount
    FROM dbo.YourTableName
    GROUP BY EvS_VoucherCode

Share This Page