Thanks very much for your suggestion.
I figured that one out as:
SELECT sum(cast(ques.answer_value AS INTEGER)) AS actytd, eval_id
FROM QUESTION_DATA AS ques, VALID_ANSWERS AS ans, #ytd_eval1a
WHERE ques.score_value_ind = 'S'
and ques.tx_id = #ytd_eval1a.tx_id
and ques.code = ans.code
and ques.answer_value = ans.answer_value
and ans.valid_answer <> 'NA'
GROUP BY eval_id
I was able to eliminate the value assignment.
But now I'm stuck on the next query that has to be broken out by eval_id because it has subselects. I am already using 2 temp tables so I'm hesitating to use any more.
What's your take on grouping the following by eval_id?
SELECT sum(q.maxValues)
FROM
(
SELECT DISTINCT code, MAX(answer_value) AS maxValues
FROM VALID_ANSWERS
WHERE VALID_ANSWERS.code in
(
SELECT ques.code
FROM QUESTION_DATA AS ques, VALID_ANSWERS AS ans, #ytd_eval1a
WHERE ques.score_value_ind = 'S'
and ques.tx_id = #ytd_eval1a.tx_id
and ques.code = ans.code
and ques.answer_value = ans.answer_value
and ans.valid_answer <> 'NA')
GROUP BY code
)
AS q
thank you very much for any and all help!!!!!! I'm pulling my hair out on this one.