Click here to Skip to main content
15,886,825 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
Hi,

I want to return decimal or float values using stored procedure

this is my stored procedure its returns only integer value

SQL
GO
ALTER PROCEDURE [dbo].[uspGetVote](@TeamID int,@CardID int)

AS

BEGIN


select avg(VoteValue) as [AverageVoteValue] from Vote where LastModifiedDateTime in
(select top 7 LastModifiedDateTime from  Vote where TeamID=@TeamID and CardID=@CardID order by LastModifiedDateTime desc)

END



please give me query for returning the decimal values
Posted

Consult the BOL for more example/sample.
DECLARE @value int
SET @value = 31

-- SELECT CONVERT(decimal(14,2),avg(VoteValue)) ... -- <-- your code
		
SELECT CONVERT(decimal(14,2),avg(@value))	

returns:
34.00

SELECT CONVERT(decimal(14,7),avg(@value))

returns:
34.0000000

Etcetera ...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900