RE: Query Resulting error
Don't use DOUBLE (or FLOAT) for monetary values. Use DECIMAL(...). Two decimal places ( ,2) suffices for most countries, but not all. DOUBLE values have been rounded when converted from decimal to binary. Multiply creates another rounding. The end result may look the same when converted from binary to decimal and displayed to only two decimal places, but the underlying values may be !=. -Original Message- From: Trimurthy [mailto:trimur...@tulassi.com] Sent: Saturday, December 29, 2012 4:26 AM To: mysql@lists.mysql.com Subject: Query Resulting error hi, i am working with mysql 5.1.36 and i wrote the following query. select total,quantity*price from sales where total != quantity*price and salesid=122; OUT PUT: totalquatity*price 330.46 330.46 here quantity is 15.5 and price is 21.32 both the values and data types are double(total,quantity and price). can anyone tell me why this is happening. Normal 0 false false false EN-US X-NONE AR-SA Thanks Kind Regards, TRIMURTHY -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Query Resulting error
hi, i am working with mysql 5.1.36 and i wrote the following query. select total,quantity*price from sales where total != quantity*price and salesid=122; OUT PUT: totalquatity*price 330.46 330.46 here quantity is 15.5 and price is 21.32 both the values and data types are double(total,quantity and price). can anyone tell me why this is happening. Normal 0 false false false EN-US X-NONE AR-SA Thanks Kind Regards, TRIMURTHY
Re: Query Resulting error
Hi To me it looks like quantity is being multiplied by the price and then added to total. Try something like this SELECT total,(quantity*price) as QP from sales where total !=QP AND salesid=122 On 2012-12-29, at 7:25 AM, Trimurthy wrote: hi, i am working with mysql 5.1.36 and i wrote the following query. select total,quantity*price from sales where total != quantity*price and salesid=122; OUT PUT: totalquatity*price 330.46 330.46 here quantity is 15.5 and price is 21.32 both the values and data types are double(total,quantity and price). can anyone tell me why this is happening. Normal 0 false false false EN-US X-NONE AR-SA Thanks Kind Regards, TRIMURTHY -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql