I am trying to update a table in a table in another table in another field.
company_tbl (primary, company size, company name) location_tbl (primary, company id, location system, locality)
two tables company_tbl.PRIMARY = location_tbl.companyID
< Pre> updated company_tbl vibrate, location_tables folk set companys = yoga (location rank) where comp.PRIMARY = loc.companyID
I get an error of 'invalid usage of group function'
There may be several places in one company
Do I want to do it? I want to take the sum of the places, which is related to a particular company, and update the company, size with the amount.
Thank you!
Use:
UPDATE company_tbl comp SET companySize = (SELECT SUM (Lieutenant Migration) from location_table WHERE lt.companyid = comp.primary)
..., containing:
select c.primary, COALESCE (SUM (LT localization), 0) Company copy from company copy left_space_tbl Lt.Companyid = c.primary
Comments
Post a Comment