Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Multiple sum and join

Author  Topic 

Ratamahatta
Starting Member

3 Posts

Posted - 2008-10-05 : 07:19:13
I posted this in the sql 2000 section but it turned out to be an access issue, any help would be appreciated.

quote:
I have two tables i would like to join to show bonus earned this month and total this year.
First table: empl.

emplID | Name
1 | Bob
2 | James

Second table: Bonus.

empl_id | month | Bonus
1 | 1 | 1000
2 | 1 | 750
1 | 2 | 500
2 | 2 | 1000
1 | 3 | 250
2 | 3 | 500

The output im looking for is (bonus month 3):
Name | Bonus this month | Bonus total
Bob | 250 | 1750
James | 500 | 2250

This is the closest i have got and it fails. So if anyone can point me in the right direction i would be very thankful.

Failing query:

select e.name, sum(b.bonus) as total, sum(b1.bonus) as thismth from (empl as e INNER JOIN bonus as b on e.emplID=b.empl_id) INNER JOIN bonus as b1 on e.emplID=b1.empl_id group by e.name

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-05 : 07:48:47
this might help you

http://support.microsoft.com/kb/290136
Go to Top of Page
   

- Advertisement -