I have a table in PostgreSQL of users that holds 2 fields:

ID (int) || Name (text)

when I insert a new user to the table, the table should set his ID as the next index in the ID list, i.e if the IDs in the list are: 1, 2, 3
the next user that will be added will be assigned with the ID = 4.

To do that, I'm getting the max ID value in the table and incrementing it, the problem is that if the table is empty, MAX function returns null, in order to deal with that - I decided to use COALESCE as follows:

```
INSERT INTO users VALUES COALESCE(0,(SELECT MAX(id) FROM users) + 1), 'Smith');

```

Which intended to put 0 in case a NULL value is returned from MAX function.

Problem is that while `SELECT MAX(id) FROM USERS` does return a NULL value, when i add the `+1` it gives an error.

How can that be fixed? I have the intention to keep it in one query.