SQL Syntax

Mondeo

Well-known member
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Ive got this

SELECT id, memberID, ((Q + V + C + R + T) / 5) AS TotalScore
FROM dbo.csd_MemberFeedbacks

The 5 values are integers in the database.

The statement runs fine but TotalScore is always returned as a whole number.

For example if the values in the DB are 3,4,5,4,3 then I want 3.8 to be returned, but I get 4.

How can I fix it so TotalScore in a decimal.

Thanks
 
Convert(...)

Try the CONVERT function:

Code:
SELECT id, memberID,
   (CONVERT(real, Q + V + C + R + T) / 5.0)
AS TotalScore
FROM dbo.csd_MemberFeedbacks

Good luck :cool:
 
Back
Top