The way I read this, you need to use UNION:
SELECT a.val0
FROM TABLE a
WHERE a.type = 0
UNION ALL
SELECT a.val1
FROM TABLE a
WHERE a.type = 1
UNION ALL ...
UNION ALL doesn't remove duplicates, and is faster than UNION (because it removes duplicates).
Doing this dynamically is possible.