I'm trying to add a generated column to a postgresql table. It's a percentage derived from two other columns. To avoid division by zero errors I've used the method outlined in this answer.
ALTER TABLE passing
ADD COLUMN pass_completion DECIMAL(4,1)
GENERATED ALWAYS AS (cmp_pass / coalesce(nullif(att_pass,0),1) * 100) STORED;
The resulting column output is always 0.0
so something has gone wrong.
I appreciate any help!