Hello.
Would one of you great people please help me?
When I run this query, @score s/b 66.7 but 67 is printing (so I am assuming that the value that's being returned for @score = 67) but I can't figure out why.
I appreciate your help, as always
--------------------
Declare @s1 FLOAT
Declare @s2 FLOAT
Declare @tx_id INT
Declare @score decimal
Set NOCOUNT on
--Set @tx_id = LTrim( RTrim( @tx_id) )
Set @tx_id = LTrim( RTrim( '79004') )
--Get the sum of the actual question answer values
SELECT @s1 = convert(numeric(8,4),sum(cast(ques.answer_value AS INTEGER)))
FROM QUESTION_DATA AS ques, VALID_ANSWERS AS ans
WHERE ques.score_value_ind = 'S'
and tx_id = @tx_id
and ques.code = ans.code
and ques.answer_value = ans.answer_value
and ans.valid_answer <> 'NA'
SELECT @s2 = sum(ques.max_answer_value)
FROM QUESTION_DATA AS ques
WHERE tx_id = @tx_id
AND max_answer_value is not null
SELECT @score = convert(decimal(4,1),convert(decimal(4,1),(@s1*100)) / convert(decimal(4,1),@s2))
print @s1
print @s2
print @score
--------------
Would one of you great people please help me?
When I run this query, @score s/b 66.7 but 67 is printing (so I am assuming that the value that's being returned for @score = 67) but I can't figure out why.
I appreciate your help, as always
--------------------
Declare @s1 FLOAT
Declare @s2 FLOAT
Declare @tx_id INT
Declare @score decimal
Set NOCOUNT on
--Set @tx_id = LTrim( RTrim( @tx_id) )
Set @tx_id = LTrim( RTrim( '79004') )
--Get the sum of the actual question answer values
SELECT @s1 = convert(numeric(8,4),sum(cast(ques.answer_value AS INTEGER)))
FROM QUESTION_DATA AS ques, VALID_ANSWERS AS ans
WHERE ques.score_value_ind = 'S'
and tx_id = @tx_id
and ques.code = ans.code
and ques.answer_value = ans.answer_value
and ans.valid_answer <> 'NA'
SELECT @s2 = sum(ques.max_answer_value)
FROM QUESTION_DATA AS ques
WHERE tx_id = @tx_id
AND max_answer_value is not null
SELECT @score = convert(decimal(4,1),convert(decimal(4,1),(@s1*100)) / convert(decimal(4,1),@s2))
print @s1
print @s2
print @score
--------------