sql - MySQL query returning invalid clause error -
i have query:
select f.name f_name, f.address f_address, f.business f_business, f.web f_web, f.id_service f_id_service, f.id_city f_id_city, f.id_firm f_id_firm, f.phone f_phone, p.name p_name firm f left join price p on p.id_service=f.id_service , p.id_city=f.id_city , p.id_firm=f.id_firm p.id_city='73041' , p.include='1' , p.blocked='0' , f.blocked='0'and p.id_group='44' , p.id_subgroup='369' group f.name order f.name asc i following error:
msg 8120, level 16, state 1, line 4 column 'firm.address' invalid in select list because not contained in either aggregate function or group clause. why , how can fix it?
you should consider giving question better heading..
you can not access columns that's not in group in select (you may have put them in aggregate function min(...) or max(...)).
i'm not sure why have group in query since don't aggregates?
you may want remove group together. may want put columns in group by. or may want remove group , add distinct clause after select in sql (removing group give 1 result each row).
my guess want sql this:
select f.name f_name, f.address f_address, f.business f_business, f.web f_web, f.id_service f_id_service, f.id_city f_id_city, f.id_firm f_id_firm, f.phone f_phone, p.name p_name, sum(p.somekind_of_column) sumofprice firm f left join price p on p.id_service=f.id_service , p.id_city=f.id_city , p.id_firm=f.id_firm p.id_city='73041' , p.include='1' , p.blocked='0' , f.blocked='0' , p.id_group='44' , p.id_subgroup='369' group f.name, f.address, f.business , f.web, f.id_service , f.id_city , f.id_firm , f.phone , p.name order f.name asc
Comments
Post a Comment