Reputation: 183
I have a Runs table and this is my query
SELECT (pass*100)/total as pass from Runs where runId=1
I want the data type of the result returned to be decimal
type.
How do I specify that ?
I did this after the query :
decimal.TryParse(reader["pass"].ToString(), out d1); d1 should be 83.4 but it is 83
Upvotes: 0
Views: 77
Reputation: 3620
use cast
to convert it to decimal and provide precision and scale accordingly
select cast((pass*100)/total as decimal(4,2)) from Runs where runId=1
Upvotes: 1
Reputation: 44766
Use CAST
:
SELECT CAST((pass*100)/total as decimal) as pass from Runs where runId=1
(Provide DECIMAL precision and scale of your choice...)
Upvotes: 0