## Error in Calculating Floor() value in SQL

 Author Message yensin 20332 SSC Rookie Group: General Forum Members Points: 31 Visits: 18 Hi all, I need to calculate numbers of money notes needed for salary preparation. I have problem with the last column, i.e. USD1. The value return is 3 instead of 2. SELECT FLOOR(2.78) ==> return 2. I am not sure why my following code return 3. DECLARE @GrossPay Decimal(12,2)SET @GrossPay = 132.78SELECT @GrossPay,FLOOR(@GrossPay/100) AS USD100, FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50) AS USD50,FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20) AS USD20,FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20)/10) AS USD10,FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20)/10))*10)/5) AS USD5,FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20)/10))*10-(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50 - (FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100 -(FLOOR((@GrossPay - FLOOR(@GrossPay/100)*100)/50))*50)/20))*20)/10))*10)/5))*5)/1) AS USD1Hope that anyone can help me with this. Thanks in advance!