The starting point
------------------

Suppose I have a table `devTest` that looks like this:

```
+----+------+  
| id | j    |  
+----+------+  
|  1 |    5 |  
|  2 |    9 |  
|  3 |    4 |  
|  4 |    7 |  
+----+------+

```

The goal
--------

I want a column specifying the row's deviation from the mean in the j column (expressed in standard deviations). That is, the table would look like this:

```
+----+------+------------+
| id | j    | jDev       |
+----+------+------------+
|  1 |    5 | -0.5637345 |
|  2 |    9 | 1.2402159  |
|  3 |    4 | -1.0147221 |
|  4 |    7 | 0.3382407  |
+----+------+------------+

```

What I've tried
---------------

```
>alter table devTest add column jDev decimal as ((j - avg(j)) / std(j));

```

To which I receive an error indicating that aggregate functions can't be used in the definition of a generated column:

```
ERROR 1901 (HY000): Function or expression 'avg()' cannot be used in the 
GENERATED ALWAYS AS clause of `jDev`

```

Making this kind of column must be pretty common, so I'd love to know the best solution!