7
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
我得到這些錯誤
Msg 156,Level 15,State 1,Line 7
錯誤的同步在關鍵字'SELECT'附近收稅。
Msg 156,Level 15,State 1,Line 8
關鍵字'in'附近的語法不正確。
如何使用透視將字符串分組在透視列下?
@Downvoter關心評論?我的問題沒有什麼是錯的。 – 2013-05-07 13:44:51
當然,這是一個有趣的問題。來自我的+1 ... – 2016-07-01 04:20:40