Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to do sum the salarie of employes if empnames are equal in ssis Expand / Collapse
Author
Message
Posted Saturday, December 11, 2010 6:56 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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, 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
Post #1033302
Posted Saturday, December 11, 2010 10:03 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 11:34 PM
Points: 7,040, Visits: 12,966
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1033323
Posted Saturday, December 11, 2010 10:15 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:36 AM
Points: 5,573, Visits: 24,805
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

Before posting a performance problem please read
Post #1033327
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse