sql clause

  • Thread starter Thread starter joy
  • Start date Start date
J

joy

I have 2 tables (members, account)
members has these fields:
memberCode (index and unique)
Lname
Fname

account has these fields:
customer (index but not unique)
trans

I wrote

SELECT members.fname as first, members.lname as family,
sum(account.trans) as total
FROM members INNER JOIN account
ON members.memberCode=account.customer
GROUP BY memberCode

and i get this error:
You tried to excute a query that does not include the
specified expression 'fname' as part of an aggregate
function

what do i do worng?
please help
joy
 
You need to group by the fields used in your query upon which you are not performing a function (e.g sum). So your code should read

SELECT members.fname as first, members.lname as family
sum(account.trans) as total
FROM members INNER JOIN accoun
ON members.memberCode=account.custome
GROUP BY members.fname ,members.lname

Regard
Rowan
 
Thank you rowan so much
joy
-----Original Message-----
You need to group by the fields used in your query upon
which you are not performing a function (e.g sum). So your
code should read:
 
Back
Top