title: How to work out Percent in PostgreSQL using Count
body: <p>I want to work out the percentage of reads (records) that have a quality score above a certain threshold. I got both values needed using the below queries.</p>
  
  <p><code>select count(read_header) from k12_read where quality_score  &gt; 25;</code></p>
  
  <p><code>select count(read_header) from k12_read;</code></p>
  
  <p>I tried this below however it just returns 0.0</p>
  
  <p><code>select (select count(*) from k12_read where quality_score &gt;= 25) / (select count(*) from k12_read) * 100.0 as percentage;</code></p>
  
  <p>I also <a href="https://stackoverflow.com/a/1183936">found this online</a> but it also just returned 0.0 when tried.</p>
  
  <p>Any ideas on how I can achieve this?</p>