Andrea Girardi
Andrea Girardi

Reputation: 4437

Return multiple rows on a single record

I need to retrieve this result:

ROW1.id | ROW2.id | ROW3.id | ROW4.id
   1    |    2    |    3    |    4

starting from this result select * from Table:

id | value
1  | sample1
2  | sample2
3  | sample3
4  | sample4

any idea?

thanks, Andrea

Upvotes: 1

Views: 278

Answers (2)

BitKFu
BitKFu

Reputation: 3697

you can do something like that:

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

Upvotes: 1

froadie
froadie

Reputation: 83183

Try looking into SQL's pivot

Upvotes: 1

Related Questions