How to make a generated 'sum of row' column in SQLite?

225 views Asked by At

I'm trying to create a table in SQLite that contains a text column, several integer columns, and a final column that is the sum of all integers in that row.

This is my attempt:

CREATE TABLE example1(name TEXT,
                      num1 INT,
                      num2 INT,
                      num3 INT,
                      num_total REAL GENERATED ALWAYS AS (num1 + num2 + num3));

And the error message is

Execution finished with errors.
Result: near "AS": syntax error
At line 1:
CREATE TABLE example1(name TEXT,
                      num1 INT,
                      num2 INT,
                      num3 INT,
                      num_total REAL GENERATED ALWAYS AS

Any help is much appreciated, thanks.

0

There are 0 answers