Problem Trying to Sum SQL decimals with specific ID
-
I am 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.
/* Sum payments made to invoice number */ $payments_table = $wpdb->prefix . "_payments"; $invoice_id = '999999999'; $result = $wpdb->query('SELECT sum(value) FROM '.$payments_table.' WHERE invoice_id = '.$invoice_id.''); echo $result;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’
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Problem Trying to Sum SQL decimals with specific ID’ is closed to new replies.