I want to set a column to a specific value of 1/COUNT(*) in an SQL table. I am wondering how to do this.
To make it clearer, consider the following example. We have a table table1
TABLE1:
A | B | C
---------------------
1 | 9 | 0
2 | 7 | 0
4 | 8 | 0
3 | 6 | 0
I want to set the column C with value of 1/COUNT(*), in this case, is 0.25. So the result should be:
TABLE1:
A | B | C
---------------------
1 | 9 | 0.25
2 | 7 | 0.25
4 | 8 | 0.25
3 | 6 | 0.25
However, I tried the following code:
UPDATE TABLE
SET C = 1/COUNT(*)
It does not work and gives me an error:
Error: ERROR: aggregate functions are not allowed in UPDATE
Position: 21
How am I supposed to do this in SQL? Thank you!