Premetto che è la prima volta che scrivo sul vostro forum.
Ho creato questa SQL:
Questo codice è giusto e mi tira fuori 3 colonne per 2 righe:codice:select tc.Curr, sum(tc.Sep_StdY), sum(tc.Jan_CY) from tbl_tmp_conversion c, kmsexport.tbl_cta_kms_data cd, kmsexport.tbl_kmsrefcosts rc, kmsexport.tbl_kms k, kmsexport.tbl_causalscategories cc, tbl_kmstargetcosts tc WHERE c.idUtente = 'F04305A' and c.IdKeyModel = tc.idKeyModel and c.Year = 2011 and cd.CostType = 'TVMC' and cd.`Plant Desc` = 'All Plants' and cd.RowType = 'D' and rc.Plant = 'All' and rc.Product = cd.`Product Code` and tc.Product = cd.`Product Code` and cd.KMS_Year = 2011 and rc.Year = cd.KMS_Year and tc.Year = cd.KMS_Year and k.ProductCode = cd.`Product Code` and cc.IDCausalCategory = cd.CausalID and tc.IdCasual = cd.CausalID and tc.RowType = 'D' and tc.Conditions = 'TARGET 2011' and tc.Plant = 'All Plants' and tc.CostType = 'TVMC' group by cd.`Product Code`;
CURR usd usd
sum(tc.Sep_StdY) 0 0
sum(tc.Jan_CY) 18,40174 56,0092
Problema:
i valori ritornati dalla select devono essere messi in un'altra tabella con una update; ed io ho creato questa update:
mi da questo errore: Error:24/05/2011 15.56.40 0:00:00.000: MySQL Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by cd.`Product Code`' at line 26codice:UPDATE tbl_tmp_conversion c, kmsexport.tbl_cta_kms_data cd, kmsexport.tbl_kmsrefcosts rc, kmsexport.tbl_kms k, kmsexport.tbl_causalscategories cc, tbl_kmstargetcosts tc SET c.CurrTarget = tc.Curr, c.TarReference = sum(tc.Sep_StdY) , c.TarActual = sum(tc.Apr_CY) WHERE c.idUtente = 'F04305A' and c.IdKeyModel = tc.IdKeyModel and c.Year = 2011 and cd.CostType = 'TVMC' and cd.`Plant Desc` = 'All Plants' and cd.RowType = 'D' and rc.Plant = 'All' and rc.Product = cd.`Product Code` and tc.Product = cd.`Product Code` and cd.KMS_Year = 2011 and rc.Year = cd.KMS_Year and tc.Year = cd.KMS_Year and k.ProductCode = cd.`Product Code` and cc.IDCausalCategory = cd.CausalID and tc.IdCasual = cd.CausalID and tc.RowType = 'D' and tc.Conditions = 'TARGET 2011' and tc.Plant = 'All Plants' and tc.CostType = 'TVMC' group by cd.`Product Code`;
E' abbastanza urgente, ci sono sopra da almeno 7 ore..
Ringrazio anticipatamente!
Anche se mi da errore di sintassi, sono sicuro che tutta la sitnassi è corretta e, se tolgo l'istruzione "group by" dalla query UPDATE (Che comunque sarebbe sbagliato perchè mi tornerebbe una sola riga con dati sbagliati) da il seguente errore:
Error:24/05/2011 17.06.28 0:00:00.000: MySQL Database Error: Invalid use of group function
AIUTOOOOOOOO![]()

Rispondi quotando
RISOLTO!
