Computed Columns

Often we want to compute values that are based on an existing row. Not only do we want to compute them once, but we actually want to add them as a separate column that will keep the values up to date with the row values. This is called a "Computed Column".

For example, if we have a table that looks like this:

state v1 v2
MA 10 20
VA 420 120

If we want to add a fourth column that will add the first two values, we would end up with this:

state v1 v2 sum
MA 10 20 30
VA 420 120 540

To accomplish this, we would call:

You can edit the code in this block and rerun it.

Note: Computed columns update on "add", "remove" and "change" events regardless of whether the sync property was set.