SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 change .000 to percentage.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hbadministrator
Posting Yak Master

109 Posts

Posted - 06/19/2013 :  15:39:20  Show Profile  Reply with Quote
current field salesgm.gp shows the current results.

gp
.045364
.574345
I want it to show 2 decimal places
45.26
57.43

robvolk
Most Valuable Yak

USA
15636 Posts

Posted - 06/19/2013 :  15:50:27  Show Profile  Visit robvolk's Homepage  Reply with Quote
SELECT ROUND(gp*100.0,2) gp_pct FROM salesgm
Go to Top of Page

hbadministrator
Posting Yak Master

109 Posts

Posted - 06/19/2013 :  15:57:05  Show Profile  Reply with Quote
thought the same thing, but get this. The rounding is good but I need to drop those other 4 0's.

ROUND(HB_JL_salesgm.GP * 100.0, 2)

34.750000
41.320000
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3326 Posts

Posted - 06/19/2013 :  17:23:15  Show Profile  Reply with Quote
Cast it to decimal(nn,2), for example:
SELECT CAST(ROUND(gp*100.0,2) AS DECIMAL(19,2)) gp_pct FROM salesgm
And, you do know someone will reply to this thread suggesting that you do this kind of formatting in the presentation layer, don't you?
Go to Top of Page

hbadministrator
Posting Yak Master

109 Posts

Posted - 06/20/2013 :  07:43:59  Show Profile  Reply with Quote
That is actually what I ended up doing. :)
Go to Top of Page

hbadministrator
Posting Yak Master

109 Posts

Posted - 06/20/2013 :  07:44:44  Show Profile  Reply with Quote
I was trying to get it all formatted in the back end but then said screw this I'll do it in the front end.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000