how to do sum the salarie of employes if empnames are equal in ssis

  • Hi All,

    if employee names in a table are equal then that particular employees salary should be add total, Here i am giving one simple example:

    input table is as below:

    EmpID, EmpName, Salary

    123, andy, 10000

    111, Maddy, 12000

    121, Raman, 25000

    124, Hemanth, 40000

    133, krishna, 50000

    122, andy, 20000

    134, Raman, 60000

    143, Maddy, 30000

    the output should be like:

    EmpID, EmpName, Salary

    123, andy, 10000

    122, andy, 20000

    143, Maddy, 30000

    111, Maddy, 12000

    121, Raman, 25000

    134, Raman, 60000

    124, Hemanth, 40000

    133, krishna, 50000

    EmpName, Salary

    andy, 30000

    Maddy, 42000

    Raman, 85000

    Hemanth, 40000

    krishna, 50000

  • Looks like homework... You might want to look into aggregation task or GROUP BY in TSQL.



    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]

  • Here is a GROUP BY solution

    CREATE TABLE #T(EmpId INT, EmpName VARCHAR(50),Salary MONEY)

    INSERT INTO #T

    SELECT 123, 'andy', 10000 UNION ALL

    SELECT 111, 'Maddy', 12000 UNION ALL

    SELECT 121, 'Raman', 25000 UNION ALL

    SELECT 124, 'Hemanth', 40000 UNION ALL

    SELECT 133, 'krishna', 50000 UNION ALL

    SELECT 122, 'andy', 20000 UNION ALL

    SELECT 134, 'Raman', 60000 UNION ALL

    SELECT 143, 'Maddy', 30000

    SELECT SUM(Salary),EmpName FROM #T GROUP BY EmpName

    DROP TABLE #T

    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]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply