select max(case when id=1 then name end) as name_1,
max(case when id=2 then name end) as name_2
From test
How to select multiple rows to multiple columns?
Вопрос
I have a table like this:
id name
1 a
2 b
3 c
4 d
5 e
If I do select name from tableTest where id = 1 or id = 2
, I got this:
name
a
b
But I want a result like this:
name_1 name_2
a b
-- 1, 2: Best: the value of id, or (AA, BB..) or (a, b, c,..) or anything
How can I do that
Решение
Не связан с StackOverflow