mdev11's avatar

Converting table with bigger than or equal and empty values to MYSQL

0

I have a form for MCQ scale called "Spence" which consists of 6 groups of questions. Each answer is a number like this:

1- Question 1

Never(0 points) Sometimes(1 point) Often(2 points) Always(3 points)

At the end of the test, each group's total score is calculated from the answers. Then with this score, I open a table provided by the test to get some other values like T-Score.

I want to convert the tables they provided to MYSQL (one or multiple MYSQL tables). This is one of the tables: https://www.scaswebsite.com/wp-content/uploads/2021/07/SCAS-P-Boys-7-9-FinalJune2018copyV2.pdf

What happens is that I have a value with one of the 6 columns on the left to get the values of the 3 columns to the right.

The issue is that some values on the left columns look like this >=8 and this 4-5.

I was thinking of creating a table with this structure:

id | min_ocd | max_ocd | min_social_phobia | max_social_phobia | ..  | total_scas | t_score 
1  | 0       | 0       | 13                | 13                | ..  | 14         | 48  
.. | ..      | ..      | ..                | ..                | ..  | ..
10 | 8       | 1000    | 13                | 13                | ..  | >=53       | >=70

Query example where 1 is the total score from answers:

SELECT 
    t_score
FROM table
WHERE total_ocd_raw_score BETWEEN min_ocd and max_ocd

There are 4 tables like the one in the screenshot.

Is there a better way with some SQL functions or a different structure?

0 likes
0 replies

Please or to participate in this conversation.