I have a database table with a grade_range column, the rows of this column contain duplicate values all separated by a comma (like a list).
grade_range
"Pre-K, Pre-K, Pre-K"
"Pre-K, K-9, K-9"
"Pre-K, K-7, 9-12"
"Pre-K, K-7, K-7"
"Pre-K, K-6"
"Pre-K, K-5"
I want to update these records so that I am only left with the unique values in the rows of this column, like this
grade_range
"Pre-K"
"Pre-K, K-9"
"Pre-K, K-7, 9-12"
"Pre-K, K-7"
"Pre-K, K-6"
"Pre-K, K-5"
Distinct column values can be easily selected in SQL using -
SELECT DISTINCT grade_range FROM dev.school
but, I am not sure how to select/update distinct values inside a row-cell. One way I thought of doing was to manipulate this data in Excel and then updating records using an UPDATE
statement based on the same sid
s
Any suggestion on accomplishing this in SQL?