title: $wpdb query to sum SQL decimals from column where they match a specific ID
body: <p>I am building a WordPress plugin that uses custom tables I've built within the Wordpress data save. In one file I'm trying to add up all the values within a decimal column where the ID is equal to a queried ID. I have tried many solutions and nothing seems to work. The current solution seems to provide an answer however it is the wrong one.</p>
  
  <pre><code>/* Sum payments made to invoice number */
  
  $payments_table = $wpdb-&gt;prefix . "_payments";
  
  $invoice_id = '999999999';
  
  
  $result = $wpdb-&gt;query('SELECT sum(value) FROM '.$payments_table.' WHERE invoice_id = '.$invoice_id.'');
  
  echo $result;
  </code></pre>
  
  <p>In the database there are currently two payments of '0.001' for invoice '999999999' so I would expect the sum to be '0.002' however the code returns '1'</p>