Query + calculated field lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2012-01-09 08:05 Hello guys, I have a query with a calculated field (product) which is the product of the fields field1 and field2. This query I want to show it in a DBGrid and if I change the values ​​of the cell that you want to update the value of the product. How do I manage this calculated field? Code: [Select]select campo1, campo2, (campo1*campo2) as prodotto FROM Tabella; ---------------------------------------------------------------------- ludob · 2012-01-09 09:34 To do this you need to use calculated fields in the dataset. Change your query to Code: [Select]select campo1, campo2 FROM Tabella; double click on the TSQLQuery and add a calculated field named 'prodotto', type Float (don't forget to add the 2 existing fields campo1, campo2 if they aren't already defined. Click on the + sign to get them from the fielddefs.). In TSQLQuery.OnCalcFields add Code: [Select]SQLQuery1.FieldByName('prodotto').AsFloat:=SQLQuery1.Fie ldByName('campo1').AsFloat * SQLQuery1.FieldByName('campo2 ').AsFloat ---------------------------------------------------------------------- xinyiman · 2012-01-09 10:06 Thank you