I have the SQL following structure
| Code | label1 | label2 | label3 |
|---|---|---|---|
| code1 | sth | null | null |
| code1 | null | sth2 | null |
| code1 | sth | null | sth3 |
| code2 | null | word1 | null |
| code2 | word2 | null | null |
| code2 | null | null | word3 |
It is possible to change it using only SQL functions and queries into :
| Code | label1 | label2 | label3 |
|---|---|---|---|
| code1 | sth | sth2 | sth3 |
| code2 | word2 | word1 | word3 |
>Solution :
Aggregate functions like min and max ignore nulls, so you could group by the code column and aggregate over the rest of them:
SELECT code, MAX(label1), MAX(label2), MAX(label3)
FROM mytable
GROUP BY code