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
 General SQL Server Forums
 New to SQL Server Programming
 can u plz help this???

Author  Topic 

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 00:09:19
hi. every one
can u help this
my question is
select 55/8
answer is 6

i want my answer in fractions also can u help this

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-02 : 00:14:12
Use this:-
select 55/CAST(8 AS float)
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 00:17:13
thank u
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-02 : 00:21:43
integer divide by integer will give you back the result in integer.

use select 55.0 / 8 or select 55 / 8.0. As long as anyone of the numerator or denominator is a decimal value, SQL Server will convert the integer to decimal and compute it and the result will be in decimal.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 00:29:57
thank u
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 01:06:05
can u help without using cast
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-02 : 01:13:53
use khtan's soln
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 01:18:18
can u help without using cast and also not using 55.0 and 8.0
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-02 : 01:20:51
quote:
Originally posted by raky

can u help without using cast and also not using 55.0 and 8.0


use convert() ?
What is your consideration ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-01-02 : 01:28:37
thank u
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-02 : 05:08:26
quote:
Originally posted by raky

can u help without using cast and also not using 55.0 and 8.0


Multiply numerator by 1.0

select 8*1.0/5

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-01-02 : 06:00:58
quote:
Originally posted by madhivanan

quote:
Originally posted by raky

can u help without using cast and also not using 55.0 and 8.0


Multiply numerator by 1.0

select 8*1.0/5

Madhivanan

Failing to plan is Planning to fail



Multiply denominator by 1.0


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-02 : 07:05:23
Whatever it is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -