Hello SC users,
First of all, please note that I’m pretty new to all of this.
Right now our company has a working application using a MySQL database and I’m trying to create reports for this app as a separate app. I’m using Grid.
The table I have is as follows: ID, value1, value2, value3 etc…
What Im trying to do is add a calculated field at the end of the table, that will be showing (value1 + value2 - value3), for each row - its own value.
So what I did so far is: I’ve created a new field “total” and entered the following sql statement for it:
SELECT value1 + value2 - value3
FROM mytable
what it does - it shows the correct calculation but on each row it puts this calculation for all rows. (a list of all of them in one field)
Example: Lets say I have 3 records in mytable, using the SELECT value1 + value2 - value3 FROM mytable I get the following:
[table=“width: 500”]
[tr]
[td]ID[/td]
[td]value1[/td]
[td]value2[/td]
[td]value3[/td]
[td]total[/td]
[/tr]
[tr]
[td]1[/td]
[td]25[/td]
[td]30[/td]
[td]5[/td]
[td]50[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]45[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]40[/td]
[/tr]
[tr]
[td]2[/td]
[td]35[/td]
[td]20[/td]
[td]10[/td]
[td]50[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]45[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]40[/td]
[/tr]
[tr]
[td]3[/td]
[td]45[/td]
[td]35[/td]
[td]40[/td]
[td]50[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]45[/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]40[/td]
[/tr]
[/table]
and I obviously want it to be like that:
[table=“width: 500”]
[tr]
[td]ID[/td]
[td]value1[/td]
[td]value2[/td]
[td]value3[/td]
[td]total[/td]
[/tr]
[tr]
[td]1[/td]
[td]25[/td]
[td]30[/td]
[td]5[/td]
[td]50[/td]
[/tr]
[tr]
[td]2[/td]
[td]35[/td]
[td]20[/td]
[td]10[/td]
[td]45[/td]
[/tr]
[tr]
[td]3[/td]
[td]45[/td]
[td]35[/td]
[td]40[/td]
[td]40[/td]
[/tr]
[/table]
Please advise. Im on SC version 8.