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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -