I have a strange problem with the float data type.
Please find the screen shot below.

Query 1 gives a record. Where as Query 2 gives no record. netbk_amt is of type float in the table.
Also, when i change the 1st query to >= (convert(float, 100001)), it doesn’t give any records.
Looks like the value is > 1000000 but < 1000001. But in the table it is shown as 1000000.
Please help me to find what went wrong with this query.
Queries:
select co_id, SUM(netbk_amt) from its_deal_sum where co_id = 19237
group by co_id
having convert(float,SUM(netbk_amt)) >= convert(float,1000000)
select co_id, SUM(netbk_amt) from its_deal_sum where co_id = 19237
group by co_id
having convert(float,SUM(netbk_amt)) <= convert(float,1000000)
I kind of did this as suggested in comments,
select co_id, SUM(netbk_amt) from its_deal_sum where co_id = 19237 group by co_id having convert(money,SUM(netbk_amt)) = convert(money,1000000)
as a temporary fix. But looking for a robust fix with the float, ignoring the fractions.
If
is all what you want – it is very easy.
Result set: