In a survey, a row with the question name 3a should equal the sum of the responses from the questions with the names 1a and 2a. This is the code I have:
UPDATE acrl.ACRLData_Edited_Test
SET question_textvalue =
cast(
(SELECT question_textvalue
FROM acrl.ACRLData_Edited_Test a2
WHERE a2.ipeds_id = a.ipeds_id
and a2.question_name = a.question_name and a2.question_name LIKE '1a.%'
) as decimal(10,2))
+ cast(
(SELECT question_textvalue
FROM acrl.ACRLData_Edited_Test a2
WHERE a2.ipeds_id = a.ipeds_id
and a2.question_name = a.question_name and a2.question_name LIKE '2a.%'
) as decimal(10,2))
FROM acrl.ACRLData_Edited_Test a
WHERE a.question_name LIKE '3a.%'
But it doesn't seem to work at all. When I run it, the survey responses/rows with the question 3a" still show Null, instead of the number.
For example, I have an entry with the 1a response as 4.7, the 2a response as 3.9 and the 3a response is NULL. It should be 8.6 in that scenario.