Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 24th, 2007, 12:00 PM
CptCrusty1 CptCrusty1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Location: In Constant Chaos
Posts: 1 CptCrusty1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 20 sec
Reputation Power: 0
Convert to a percent

I have a query result that I'm trying to convert to a percent. The view v_DateRange is just pulling all records from the source table within a given date range, no biggy. I'm tried Cast again, but I'm getting errors. Here's the language:

Code:
select ((a.Success/b.Valid)*100) as CCR
from 
	(SELECT cast(count(*) as numeric(10,2)) as Success
	FROM v_daterange 
	WHERE SuccessFlag = 1) a,

	(SELECT cast(count(*) as numeric(10,2)) As Valid
	FROM v_daterange 
	WHERE ValidFlag = 1) b


My result is coming up as 60.8889 bla bla bla... I need to chop this to 2 decimals. I tried casting to Varchar(5) but that didn't work either... arithmetic overflow.... something like that.... any ideas?

Thanks
Crusty.

p.s. I'm new... how do I change my avitar?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Convert to a percent


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT