# Thread: How to use floor to ....

1. Registered User
Join Date
Jan 2004
Posts
19

## Unanswered: How to use floor to ....

I am in a SQL class and the teacher has asked us to update a value by 100 if the id number is even using the floor function.

I am not looking for someone to write the expresion, but someone to explain how the floor function could be used to do this.

Any help would be greatly appreciated.

2. Registered User
Join Date
Oct 2003
Location
Newcastle, Australia
Posts
51
your lecturere probably wants to to divide your number by 2, get the floor() value and multiply it by 2 again to see if it is the same value

eg
7/2 = 3.5
floor(3.5) = 3
3 x 2 = 6

so we know 7 is not even

8/2 = 4
floor(4) = 4
4 x 2 = 8

so we know 8 is even

3. Registered User
Join Date
Jan 2004
Posts
19
Thanks a ton.

That was just the info i need to build my query. My brain must have been mush to not figure out that simple math.

just for FYI here is the query i cam up with, nothing complicated but with your help on the math i was able to come through.

UPDATE Salaries
SET Salary = Salary + 100
WHERE floor(empid / 2) * 2 = empid

UPDATE Salaries
SET Salary = Salary + 200
WHERE floor(empid / 2) * 2 != empid

Thanks again Matt, your a lifesaver!!!!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•