Can I create a calculated field in a Retool Database?

Let's say, for a simple example, that I have four columns in the database.

Operator | Boolean
Value1 | Integer
Value2 | Integer
Total | Integer

I want to do something simple in the database:

if (Operator) Total = Value1 + Value2
else Total = Value1 - Value2

Is this possible?

I am not sure but you could do something using SUM

Yeah, but that's on the way out, in my query. I'm trying to find a way to have a calculated field auto-update based on the values in other columns. This is just a simplified example of that.

If you use the "Mapped value" setting of your column you should be able to display the calculated values immediately. Those values then also get registered in the table's columnMappers property which you can use for your update. How exactly to reference that depends on what kind of DB you're using though - would you mind sharing more about it?
display_calculated_values_in_table.json