Home All Groups Group Topic Archive Search About
Author
25 Aug 2005 1:25 PM
A.B.
Will the following SQL allow me to see the results of the computed column in
decimal format even if the Columns used in the calculation are defind as int:

Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards])) 'Count'

I have used it but I am not getting any decimal places. It is showing the
decimals as 0. If this is not the problem could you please make some
suggestions.

Thanks
Adam

Author
25 Aug 2005 1:34 PM
Aaron Bertrand [SQL Server MVP]
Try multiplying the arguments by 1.0, or explicitly converting the arguments
to decimal.

By arguments, I mean the individual pieces, not the result of the
calculation.

A




Show quote
"A.B." <A*@discussions.microsoft.com> wrote in message
news:836A42B5-D2D1-480B-82A5-A167007B0123@microsoft.com...
> Will the following SQL allow me to see the results of the computed column
> in
> decimal format even if the Columns used in the calculation are defind as
> int:
>
> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards]))
> 'Count'
>
> I have used it but I am not getting any decimal places. It is showing the
> decimals as 0. If this is not the problem could you please make some
> suggestions.
>
> Thanks
> Adam
Author
25 Aug 2005 1:52 PM
JP
How about something like this

select price/cast(code as money) from xyz

i.e. the denominator gets converted to 'money' type :)

Cheers,
JP (Just a programmer:))
--------------

Show quote
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:O515emXqFHA.2652@tk2msftngp13.phx.gbl...
> Try multiplying the arguments by 1.0, or explicitly converting the
> arguments to decimal.
>
> By arguments, I mean the individual pieces, not the result of the
> calculation.
>
> A
>
>
>
>
> "A.B." <A*@discussions.microsoft.com> wrote in message
> news:836A42B5-D2D1-480B-82A5-A167007B0123@microsoft.com...
>> Will the following SQL allow me to see the results of the computed column
>> in
>> decimal format even if the Columns used in the calculation are defind as
>> int:
>>
>> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards]))
>> 'Count'
>>
>> I have used it but I am not getting any decimal places. It is showing the
>> decimals as 0. If this is not the problem could you please make some
>> suggestions.
>>
>> Thanks
>> Adam
>
>
Author
25 Aug 2005 1:56 PM
JP
OR

select price/cast(code as decimal(10,4)) from xyz

Cheers,
JP (Just a Programmer;))
---------------

Show quote
"JP" <some***@somewhere.com> wrote in message
news:ucbhzwXqFHA.3104@TK2MSFTNGP12.phx.gbl...
> How about something like this
>
> select price/cast(code as money) from xyz
>
> i.e. the denominator gets converted to 'money' type :)
>
> Cheers,
> JP (Just a programmer:))
> --------------
>
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in
> message news:O515emXqFHA.2652@tk2msftngp13.phx.gbl...
>> Try multiplying the arguments by 1.0, or explicitly converting the
>> arguments to decimal.
>>
>> By arguments, I mean the individual pieces, not the result of the
>> calculation.
>>
>> A
>>
>>
>>
>>
>> "A.B." <A*@discussions.microsoft.com> wrote in message
>> news:836A42B5-D2D1-480B-82A5-A167007B0123@microsoft.com...
>>> Will the following SQL allow me to see the results of the computed
>>> column in
>>> decimal format even if the Columns used in the calculation are defind as
>>> int:
>>>
>>> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards]))
>>> 'Count'
>>>
>>> I have used it but I am not getting any decimal places. It is showing
>>> the
>>> decimals as 0. If this is not the problem could you please make some
>>> suggestions.
>>>
>>> Thanks
>>> Adam
>>
>>
>
>
Author
25 Aug 2005 1:35 PM
Alejandro Mesa
You have to change the formula instead.

((#Operator2.[Count] * 1000.00)/#Closed2.[Dyed Yards])


AMB

Show quote
"A.B." wrote:

> Will the following SQL allow me to see the results of the computed column in
> decimal format even if the Columns used in the calculation are defind as int:
>
> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards])) 'Count'
>
> I have used it but I am not getting any decimal places. It is showing the
> decimals as 0. If this is not the problem could you please make some
> suggestions.
>
> Thanks
> Adam
Author
25 Aug 2005 1:36 PM
Perayu
Can you try this:
Convert(Dec(10,5), ((#Operator2.[Count]*1000.0)/#Closed2.[Dyed Yards]))
'Count'

Perayu

Show quote
"A.B." wrote:

> Will the following SQL allow me to see the results of the computed column in
> decimal format even if the Columns used in the calculation are defind as int:
>
> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards])) 'Count'
>
> I have used it but I am not getting any decimal places. It is showing the
> decimals as 0. If this is not the problem could you please make some
> suggestions.
>
> Thanks
> Adam
Author
25 Aug 2005 1:56 PM
A.B.
Thanks guys, it worked

Show quote
"A.B." wrote:

> Will the following SQL allow me to see the results of the computed column in
> decimal format even if the Columns used in the calculation are defind as int:
>
> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards])) 'Count'
>
> I have used it but I am not getting any decimal places. It is showing the
> decimals as 0. If this is not the problem could you please make some
> suggestions.
>
> Thanks
> Adam
Author
25 Aug 2005 5:38 PM
Chandra
hi AB

you can try it as:

#Operator2.[Count]*1000.0)/#Closed2.[Dyed Yards] as [count]

hope this will help u

--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---------------------------------------



Show quote
"A.B." wrote:

> Will the following SQL allow me to see the results of the computed column in
> decimal format even if the Columns used in the calculation are defind as int:
>
> Convert(Dec(10,5), ((#Operator2.[Count]*1000)/#Closed2.[Dyed Yards])) 'Count'
>
> I have used it but I am not getting any decimal places. It is showing the
> decimals as 0. If this is not the problem could you please make some
> suggestions.
>
> Thanks
> Adam

AddThis Social Bookmark Button