title: Postgresql rounding to significant figures
body: <p>i've tried this significant figures query from this blog (<a href="https://www.garysieling.com/blog/postgres-significant-figures-pg_size_pretty" rel="noreferrer">https://www.garysieling.com/blog/postgres-significant-figures-pg_size_pretty</a>).</p>
  
  <p>But it seems have fixed decimal digit on it.</p>
  
  <pre><code>SELECT FLOOR(5.4321/(10 ^ FLOOR(log(5.4321)-1))) * (10 ^ FLOOR(log(5.4321)-1))
  </code></pre>
  
  <p>The result from the query above is 5.4.
  How can i achieve query to create these results?</p>
  
  <pre><code>number | sigfig
  5.4321 | 5.43
  10.987 | 10.9
  550.75 | 550
  9850.5 | 9850
  ect
  </code></pre>
  
  <p>Thank you for you help brothers!</p>