表值:
EMP_NO EMP_NAME
--------------
14 admin
1 ram
2 mohan
3 mallu
4 scoot
5 jim
6 ravi
7 manju
8 manoj
9 sarath
10 hemanth
如何将行转换为列?
答案 0 :(得分:0)
尝试以下查询oracle
select
emp_no,
rtrim (xmlagg (xmlelement (e, emp_name || ',')).extract ('//text()'), ',') enames
from
emp
group by
emp_no
;
for sql server try
SELECT *
FROM (
SELECT
emp_name
FROM tblemployee
) as s
PIVOT
(
min(emp_id)
FOR emp_id
)AS pivot