Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Join

Status
Not open for further replies.

morfasie

IS-IT--Management
Mar 28, 2004
85
ZA
If I have a table like this :
name | money | date
--------------------
group 1 | 10 | january
group 1 | 10 | february
group 1 | 10 | march

another table with memebrs in it.

I want to sum the money in the first table, and do a count on the second table, to see how many members the group has.

my join multiplies the money sum with the count etc.

select sum(a.money_received),count(*)
from schedule_premiums a
left outer join productioncalc b
on a.`group name` = b.`group name`
where a.`group name` = 'africa granite'

what type of join should I then use? I have tried everything?
 
Code:
select `group name`
     , sum(a.money_received)  
             as total_money
     , ( select count(*) 
           from productioncalc
          where `group name` 
              = a.`group name` ) 
             as member_count
  from schedule_premiums a
group
    by `group name`

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top