I have a 4-column table in postgres called mytable. The fourth column - batch - contains only null values. My goal is to update it using the UPDATE... SET commands by setting it equal to the result of a query that uses that table (in this case NTILE(), which assigne each row to one of four equal-sized bins) . For example:
UPDATE mytable
SET batch = (SELECT
NTILE(4) OVER()
FROM
mytable)
When I try the above,the code fails with an error:
ERROR: more than one row returned by a subquery used as an expression
The query by itself runs successfully. How would one update this column with one command in postgres?