SQL in Access Error using GROUP BY -
some 25 years ago learned sql. doesn't me now:)
in access have simple query:
select bank.bankid, bank.bankname, address.streetname, address.streetnumber, address.zipcode, address.city, bank.transactionfile bank left join address on bank.[bankid] = address.[bankid]
now want exclude duplicate records use distinct:
select distinct bank.bankid, bank... etc
however, not want transactionfile part of distinct selection, in order data want. thought use group statement instead:
select bank.bankid, bank.bankname, address.streetname, address.streetnumber, address.zipcode, address.city, bank.transactionfile bank left join address on bank.[bankid] = address.[bankid] group bank.bankid, bank.bankname, address.streetname, address.streetnumber, address.zipcode, address.city
but errormessage "you tried execute query not include specified expression 'transactionfile' part of aggregate function". if group bank.bankid same message on bank.bankname.
what missing here?? thanks!
all columns not in group by
need in aggregation functions. so, either remove bank.transactionfile
or use aggregation function:
select bank.bankid, bank.bankname, address.streetname, address.streetnumber, address.zipcode, address.city, max(bank.transactionfile) bank left join address on bank.[bankid] = address.[bankid] group bank.bankid, bank.bankname, address.streetname, address.streetnumber, address.zipcode, address.city;
Comments
Post a Comment