【发布时间】:2013-12-09 19:55:54
【问题描述】:
select id, productid, optionid
from tableA
where productid = 1
结果(id、productid、optionid)
1 1 1
2 1 2
3 1 5
我希望结果为 (productid, optionids):
1 1,2,5
当然,我认为下面的查询应该会产生上述结果
select productid, optionid
from tableA
group by productid
但是我把 optionid 放在什么函数里呢?
【问题讨论】:
-
你看过 Pivot 子句吗?
-
没有,第一次听说。
-
这已经被问过很多次了。只需使用 sql-server 和组连接进行快速搜索
标签: sql-server tsql