Suppose I have a table devTest
that looks like this:
+----+------+
| id | j |
+----+------+
| 1 | 5 |
|
This error makes sense because any change in your table (say you add a j
with value 0) would update your average, and this in turn would change all your generated columns. So this would be quite a bit of work for the query engine.
Another solution would be to define a view instead:
CREATE VIEW j_dev (id, j, j_dev) AS
SELECT id, j,
(j - avg(j)) / std(j) as j_dev
FROM devTest
(not sure about the create view syntax, correct me if I'm wrong)