Hi,
I have the foll
round((convert(decimal(4,0),d.new - d.old)/d.old)*100,0)
The result I get is -54.00000000000
How can I change it to only display -54
ThanksCONVERT(INT, ROUND(...))
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:A140E6DC-02B6-4A2D-93DB-7BFF7667F6F4@.microsoft.com...
> Hi,
> I have the foll
> round((convert(decimal(4,0),d.new - d.old)/d.old)*100,0)
> The result I get is -54.00000000000
> How can I change it to only display -54
> Thanks|||hi
you can do it as
round((convert(decimal(4,0),d.new - d.old)/d.old)*100)
remove the decimal after 100.
please let me know if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://groups.msn.com/SQLResource/
---
"Chris" wrote:
> Hi,
> I have the foll
> round((convert(decimal(4,0),d.new - d.old)/d.old)*100,0)
> The result I get is -54.00000000000
> How can I change it to only display -54
> Thanks|||Hi,
If I use int I get 0.
"Aaron Bertrand [SQL Server MVP]" wrote:
> CONVERT(INT, ROUND(...))
>
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:A140E6DC-02B6-4A2D-93DB-7BFF7667F6F4@.microsoft.com...
>
>|||You said you have:
SELECT round((decimal(4,0),d.new - d.old)/d.old)*100,0)
...and this yields -54.000000. So you are saying that if you change that
to:
SELECT CONVERT(INT, round((convert(decimal(4,0),d.new -
d.old)/d.old)*100,0) )
...suddenly it yields 0? I don't quite buy that, could you post a repro
(DDL, sample data)? See http://www.aspfaq.com/5006
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:906750AF-BB06-462E-91CD-5416359E89A6@.microsoft.com...
> Hi,
> If I use int I get 0.|||Are you sure you are evaluating convert(int,
round((convert(decimal(4,0),d.new - d.old)/d.old)*100,0)) ?
AMB
"Chris" wrote:
> Hi,
> If I use int I get 0.
> "Aaron Bertrand [SQL Server MVP]" wrote:
>|||Hi,
I got it to work. Wouldn't doind all these convert slow down a hugh query or
put a strain on the server?
"Aaron Bertrand [SQL Server MVP]" wrote:
> You said you have:
> SELECT round((decimal(4,0),d.new - d.old)/d.old)*100,0)
> ...and this yields -54.000000. So you are saying that if you change that
> to:
> SELECT CONVERT(INT, round((convert(decimal(4,0),d.new -
> d.old)/d.old)*100,0) )
> ...suddenly it yields 0? I don't quite buy that, could you post a repro
> (DDL, sample data)? See http://www.aspfaq.com/5006
>
> "Chris" <Chris@.discussions.microsoft.com> wrote in message
> news:906750AF-BB06-462E-91CD-5416359E89A6@.microsoft.com...
>
>|||YES! This is why formatting is better done a tthe presentation layer, not
in the database...
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:D622E951-68D1-4AA5-955D-5C4EB34F4B95@.microsoft.com...
> Hi,
> I got it to work. Wouldn't doind all these convert slow down a hugh query
> or
> put a strain on the server?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment