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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Division Operator

Author  Topic 

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-11-02 : 01:54:25
The / operator returns the quotient of the first expression divided by the second expression. Is there a way we can get the actual value after division?

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-11-02 : 02:06:50
Are you looking for the remainder of the division; use % (modulo) operator

Hemanth Gorijala
BI Architect / DBA (yuhoo!!! and now, an "Yak Master")

Exchange a Dollar, we still have ONE each.
Exchange an Idea, we have TWO each.
Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-11-02 : 02:13:47
No it is not resolving the issue. You do 13/12 in in calculator or Excel and in Query Analyzer as well you will see the problem.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-02 : 02:17:34
print convert(decimal(10,2),13.00/12.00)

--------------------
keeping it simple...
Go to Top of Page

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-11-02 : 02:20:04
Well, in SQL, int divided by int results an int.
so, convert to numeric or decimal.

Select Convert(numeric,13)/12

Hemanth Gorijala
Exchange a Dollar, we still have ONE each._______Exchange an Idea, we both have TWO each.
Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-11-02 : 02:25:09
Thanks Hemant
Go to Top of Page

hgorijal
Constraint Violating Yak Guru

277 Posts

Posted - 2004-11-02 : 03:12:16
thank Jen. She beat me to it

Hemanth Gorijala
Exchange a Dollar, we still have ONE each._______Exchange an Idea, we both have TWO each.
Go to Top of Page
   

- Advertisement -