title: How to add a leading zero based on range of values in postgres within an integer column
body: <p>New to postgres and unsure how to accomplish the following. I have a table as follows:</p>
  <pre><code>create table if not exists my_table (
     id int GENERATED BY DEFAULT AS IDENTITY primary key,
     key              int default 0
  )
  </code></pre>
  <p>What I am trying to do is take an integer value (<code>my_key</code>) and if it's <code>&gt;= 0 and &lt; 10</code> then add a leading zero (0) to it and insert it into <code>my_table.key</code></p>
  <p>I have tried to_char(my_key::integer,'09')::integer where <code>my_key = 0</code> and it doesn't insert <code>00</code> within the <code>key</code> column.</p>
  <p>Any help would be great.</p>