I'm trying to create a generated column in postgre but it's not generating right. I currently have a column for each state's number of electors and cost (for an election game) and I want to create a column that generates that state's value which divides the two then multiplies it by 1000. Here is my table definition:
CREATE TABLE public.states (
id serial4 NOT NULL,
"name" varchar NOT NULL,
"cost" int8 NULL,
electors int2 NULL
);
Here is the query that I made to insert the generated column:
ALTER TABLE public.states
ADD value float(8) generated always as (electors * 1000 / cost) STORED;
This is my result. Every column is 0 but I should be getting float values that are less than 1 and greater than 0:
