JOB ENAME
-------- ----------
ANALYST SCOTT
ANALYST FORD
CLERK SMITH
CLERK ADAMS
CLERK MILLER
CLERK JAMES
MANAGER JONES
MANAGER CLARK
MANAGER BLAKE
PRESIDENT KING
SALESMAN ALLEN
SALESMAN MARTIN
SALESMAN TURNER
SALESMAN WARD
我想格式化结果集,以便每个作业都有自己的列:
CLERKS ANALYSTS MGRS PREZ SALES
------ -------- ----- ---- ------
MILLER FORD CLARK KING TURNER
JAMES SCOTT BLAKE MARTIN
ADAMS JONES WARD
SMITH
我试过了
SELECT ANALYST, CLERK, MANAGER, PRESIDENT, SALESMAN from
(
SELECT ename, job from emp
) as st
pivot
(
SELECT ename
FOR job in (ANALYST, CLERK, MANAGER, PRESIDENT, SALESMAN)
) as pivottable
我收到这些错误
消息 156,级别 15,状态 1,第 7 行
关键字“SELECT”附近的语法不正确。
消息 156,级别 15,状态 1,第 8 行
关键字“in”附近的语法不正确。
如何使用枢轴对枢轴列下的字符串进行分组?