I have this SQL
SELECT e1.*, l1.* FROM e1
INNER JOIN l1 WHERE e1.entre_active = 'Y' AND l1.entreID = e1.entre_id
The above query works but i want to add the one below
SELECT SUM(a1.adp_amount) as amount FROM a1 WHERE a1.adp_loanID = e1.loanID;
the last part of the query is to SUM the part
Hi Joseph,
With the sum() aggregate function you'll need to use a GROUP BY clause and
specify which fields you want from e1 and l1. Something like this:
SELECT e1.field1, e1.field2, l1.field3, SUM(a1.adp_amount) as amount
FROM a1 inner join e1 on (a1.loanID = a1.adp_loanID) inner join l1 on
Oops, actually forgot my GROUP BY clause. The full query is:
SELECT e1.field1, e1.field2, l1.field3, SUM(a1.adp_amount) as amount
FROM a1
inner join e1 on (e1.loanID = a1.adp_loanID)
inner join l1 on (l1.entreID = e1.entre_ID)
WHERE e1.entre_active = 'Y'
GROUP BY e1.field1, e1.field2, l1.field3
Your problem is in SELECT e1.*, l1.*: the selected fields have to match the
ones in the GROUP BY clause, so something like:
SELECT a, b, c, SUM(d) ... GROUP BY a, b, c
hth,
Yves
-- Original Message --
Received: Tue, 13 Jan 2009 09:24:48 AM CST
From: Abah Joseph joefa...@gmail.com
To: