MySQL (v 5.5) greater than or equals to operator is adding unknown amounts
<p>I’m using the query below to sum together all repeat transactions that customers make for a given company id. Customer information is stored on the contact table and the transaction details are on the customer transactions table, the tables are linked through the contact_id. I’m getting some strange behavior in the WHERE clause. The t.amount column is a DECIMAL(15,2).</p>

<p>Using <code>WHERE t.amount &gt; 0.0</code> gives a result around 170,000. However using <code>WHERE t.amount &gt;= 0.0</code> increases the result to 200,000. Even stranger still, when I try <code>WHERE t.amount = 0.0</code>, the query returns 0.0. Data from other companies exhibits this same amount difference between <code>&gt;</code> and <code>&gt;=</code>. </p>

<p><code>SELECT SUM(amount) AS amount 
FROM (
SELECT *,
           @counter := IF(@customer_id = b.contact_id, @counter + 1, 1) AS txn_number, 
           @customer_id := b.contact_id 
    FROM (
        SELECT t.contact_id, SUM(t.amount) AS amount, t.transacted_at AS transacted_at
        FROM customer_transactions t
        INNER JOIN contact con ON con.contact_id = t.contact_id
        WHERE con.company_id = #CompanyId
        AND t.amount &gt;= 0.0
        AND t.is_paid = true
        AND t.transacted_at IS NOT NULL 
        GROUP BY t.contact_id, DATE(t.transacted_at)
        ORDER BY t.contact_id, t.transacted_at ASC
    ) AS b
) AS ct
WHERE ct.txn_number &gt; 1</code></p>

<p>In short, using only <code>&gt;</code> gives returns one result, using <code>&gt;=</code> returns a larger result even though it's being set as <code>&gt;= 0.0</code> Is there any reason why this would happen? </p>