Re[5]: SQL Server: Перевод рядов в колонки
От: DedPakhom  
Дата: 05.04.04 17:05
Оценка:
спасибо, вот так сделал:

select id1, text1, text2, comment1, comment2
from
(select top 100
rowid as r1,
id as id1,
text as text1,
comment as comment1
from dbo.test_table
order by id,text,comment) A
left join
(select top 100
rowid as r2,
id as id2,
text as text2,
comment as comment2
from dbo.test_table
order by id,text,comment) B
on
id1=id2 and r1<>r2


результат:

id text1 text2 comment1 comment2

1 aaa bbb aaa_comm bbb_comm
1 bbb aaa bbb_comm aaa_comm
2 asd ccc asd_comm ccc_comm
2 ccc asd ccc_comm asd_comm
3 ddd NULL ddd_comm NULL
4 eee NULL eee_comm NULL


a надo так:

id text1 text2 comment1 comment2

1 aaa bbb aaa_comm bbb_comm
2 asd ccc asd_comm ccc_comm
3 ddd NULL ddd_comm NULL
4 eee NULL eee_comm NULL
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.