Hi all,
i have an stored procedure that returns a value, i want to convert that value into smallmoney, is this possible and i yes how?
here is my code:
CREATE proc CP_avgloss_total
@.mID varchar(10),
@.startdate datetime,
@.enddate datetime
as
select
case
((sum(playtime))/ 3600)
when 0
then 0
else ((sum(vtp)-(sum(moneyout)))/100) / ((sum(playtime))/ 3600)
end avgloss
from dbo.total
where
machineID = @.mID
and convert(varchar,njdate,121)
between convert(varchar,@.startdate,121)
and convert(varchar,@.enddate,121)
GO
The value that needs to convert is avgloss
Hope someone can help me with this.
Cheers Wimselect cast(P1.avgloss as smallmoney) as avgloss from
(select
case
((sum(playtime))/ 3600)
when 0
then 0
else ((sum(vtp)-(sum(moneyout)))/100) / ((sum(playtime))/ 3600)
end avgloss
from dbo.total
where
machineID = @.mID
and convert(varchar,njdate,121)
between convert(varchar,@.startdate,121)
and convert(varchar,@.enddate,121)) P1|||Originally posted by marp
select cast(P1.avgloss as smallmoney) as avgloss from
(select
case
((sum(playtime))/ 3600)
when 0
then 0
else ((sum(vtp)-(sum(moneyout)))/100) / ((sum(playtime))/ 3600)
end avgloss
from dbo.total
where
machineID = @.mID
and convert(varchar,njdate,121)
between convert(varchar,@.startdate,121)
and convert(varchar,@.enddate,121)) P1
It worked thanx but i still get as outcome 4 digit behind the break
Do you know how to get 2 digits?
Thanx|||As far as I know, the smallmoney data type uses by default 4 decimal digits. If different number of decimal places are needed, "Books Online" recommends using the Decimal data type.|||Originally posted by marp
As far as I know, the smallmoney data type uses by default 4 decimal digits. If different number of decimal places are needed, "Books Online" recommends using the Decimal data type.
Thanx Man this is everything i need.
Your help was fantastic!
Kind regards Wim
No comments:
Post a Comment