Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-24 : 09:08:48
|
| Nuvera writes "I want to divide a number lets say 25 with 6. Keeping the integer part and discarding the fraction. Usually one can do this with MOD() but so far i have not been able to find this in SQL 7.0Any Suggesstions!!" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-24 : 09:10:03
|
| Use the modulo operator % in SQL:SELECT 25 % 6 --returns 1 |
 |
|
|
nivaskhan
Starting Member
17 Posts |
Posted - 2002-06-24 : 09:54:22
|
| you can also use FLOOR SELECT FLOOR(25 % 6)If u wanted it to be rounded offu can use CEILING()Regards,Nivas |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-06-24 : 10:33:07
|
| FLOOR or CEILING won't affect the modulo operation at all, there's no need to use either one of them. Also, 25 and 6 are both integers so there's nothing to round off. |
 |
|
|
nivaskhan
Starting Member
17 Posts |
Posted - 2002-06-24 : 11:31:49
|
| "I want to divide a number lets say 25 with 6. Keeping the integer part and discarding the fraction"Modulo will give the remainder part of the divisionand not the integer part .Since the requiment is only the Integer Part of the divisionFloor() will give u the Integer Part Of the DivisionSELECT FLOOR(25/6)ORSELECT CONVERT(INT,25/6)Regards,Nivas |
 |
|
|
|
|
|