
July 24th, 2007, 12:00 PM
|
|
Registered User
|
|
Join Date: Jul 2007
Location: In Constant Chaos
Posts: 1
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?
|