Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 how to do sum the salarie of employes if empnames are equal in ssis Rate Topic Display Mode Topic Options
Author
 Message
 Posted Saturday, December 11, 2010 6:56 AM
 Forum Newbie Group: General Forum Members Last Login: Monday, March 28, 2011 10:55 AM Points: 2, Visits: 94
 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, Salary123, andy, 10000111, Maddy, 12000121, Raman, 25000124, Hemanth, 40000133, krishna, 50000122, andy, 20000134, Raman, 60000143, Maddy, 30000the output should be like:EmpID, EmpName, Salary123, andy, 10000122, andy, 20000143, Maddy, 30000111, Maddy, 12000121, Raman, 25000134, Raman, 60000124, Hemanth, 40000133, krishna, 50000EmpName, Salaryandy, 30000Maddy, 42000Raman, 85000Hemanth, 40000krishna, 50000
Post #1033302
 Posted Saturday, December 11, 2010 10:03 AM
 SSCertifiable Group: General Forum Members Last Login: Yesterday @ 3:25 AM Points: 6,870, Visits: 12,511
 Looks like homework... You might want to look into aggregation task or GROUP BY in TSQL. LutzA pessimist is an optimist with experience. How to get fast answers to your question How to post performance related questionsLinks for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1033323
 Posted Saturday, December 11, 2010 10:15 AM
 SSCertifiable Group: General Forum Members Last Login: Today @ 7:01 PM Points: 5,333, Visits: 21,988
 Here is a GROUP BY solution`CREATE TABLE #T(EmpId INT, EmpName VARCHAR(50),Salary MONEY)INSERT INTO #TSELECT 123, 'andy', 10000 UNION ALLSELECT 111, 'Maddy', 12000 UNION ALLSELECT 121, 'Raman', 25000 UNION ALLSELECT 124, 'Hemanth', 40000 UNION ALLSELECT 133, 'krishna', 50000 UNION ALLSELECT 122, 'andy', 20000 UNION ALLSELECT 134, 'Raman', 60000 UNION ALLSELECT 143, 'Maddy', 30000SELECT SUM(Salary),EmpName FROM #T GROUP BY EmpNameDROP TABLE #T` If everything seems to be going well, you have obviously overlooked something. RonPlease help us, help you -before posting a question please read Before posting a performance problem please read
Post #1033327

 Permissions