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!

join in query

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 is wrong here??
 
what is wrong is that you're joining the tables :)

Code:
select sum(a.money_received)
     , ( select count(*) 
           from productioncalc 
          where `group name` 
              = a.`group name`) as rows
  from schedule_premiums a
 where a.`group name` = 'africa granite'


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

Part and Inventory Search

Sponsor

Back
Top