Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi good morning
i had a littel problem with my msaccess 2003 , i am writing the query
by using the Group class is working
and its sample code is

"select b.custrefno,SUM(b.paidamount) as paidamount from paym b,addcust a  where  b.custrefno=a.custrefno GROUP BY b.custrefno";


working prefectly

here it is working in the perfect way , by i need some extra columns so that i had added the Columns names as like name , email,mobile;
so that i had change the query just like this

"select a.email,a.name,a.mobile,b.custrefno,SUM(b.paidamount) as paidamount from paym b,addcust a  where  b.custrefno=a.custrefno GROUP BY b.custrefno";


i had also tryied like this but

"select email,name,mobile,b.custrefno,SUM(b.paidamount) as paidamount from paym b,addcust a  where  b.custrefno=a.custrefno GROUP BY b.custrefno";


but last two are not working executing prefectly , it created the error like



Error: You tried to execute a query that does not include the specified expression 'email' as part of an aggregate function.

where i am going wrong, and what's the wrong is , can any body help me

basycally my requirement is by grouping i need to get the Name and mobile number of that particular record
Posted

Put the columns that are not inside an aggregate function in the GROUP BY clause. Like this for example.

"select email,name,mobile,b.custrefno,SUM(b.paidamount) as paidamount from paym b,addcust a  where  b.custrefno=a.custrefno GROUP BY b.custrefno,email,name,mobile";
 
Share this answer
 
Try using "a.email, a.name, a.mobile" to let it know where the datasource is...

You don't need that (it's early, I'm still on my first cup of coffee)
Instead, list the email, name and mobile in the GROUP BY clause

[edit]Oops - OriginalGriff[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900