我需要检索此结果:
ROW1.id | ROW2.id | ROW3.id | ROW4.id
1 | 2 | 3 | 4
从此结果开始select * from Table
:
id | value
1 | sample1
2 | sample2
3 | sample3
4 | sample4
任何想法?
感谢, 安德烈
答案 0 :(得分:1)
尝试查看SQL的pivot
答案 1 :(得分:1)
你可以这样做:
select
(select id from table X where X.something = 123) as row1Id,
(select id from table X where X.something = 456) as row2Id,
(select id from table X where X.something = 789) as row3Id