title: psql insert into if else
body: <p>I want to make it so that when creating a user, the first user receives $ 1000 on the wallet, and the rest - $ 10 (user_id - pk)</p>
  <p>I made this request</p>
  <pre><code>INSERT INTO users (user_id, login, balance, encrypted_password) 
  select 1, 'login',
  case
          when user_id = 1 then (login = 'login', balance= 1000, encrypted_password = 'password')
          else (login = 'login', balance = 10, encrypted_password = 'password')
  end as user_id
  RETURNING user_id
  </code></pre>
  <p>but when I make this request, I get the error:</p>
  <p>ERROR: ERROR: column &quot;user_id&quot; does not exist
  LINE 4: when @user_id == 0 then (login = 'login', balance= '...
  ^
  HINT: There is a &quot;user_id&quot; column in the &quot;users&quot; table, but it cannot be referenced from this part of the query.</p>
  <p>SQL state: 42703
  character: 103</p>