Answer the question
In order to leave comments, you need to log in
Postgres insert coalesce?
this query is not working
INSERT INTO
geo
(
num_order
)
VALUES (
COALESCE(max(num_order) + 1, 1)
);
Answer the question
In order to leave comments, you need to log in
Use SELECT instead of VALUES:
INSERT INTO
geo
(
num_order
)
SELECT COALESCE(max(num_order) + 1, 1) from geo;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question