在水平行中显示SQL脚本

时间:2017-02-21 15:58:44

标签: sql pivot

我希望在不使用PIVOTING的情况下在水平线中显示SQL脚本输出。我使用的是SSRS2005,它不支持Pivoting。

function main () {

    var fso = new ActiveXObject ('Scripting.FileSystemObject')
    var output = document.getElementById ('output');
    var myWorker = new Worker ('worker1.js');
    sendOut ('Calling worker.');
    myWorker.postMessage (fso);

    myWorker.onmessage = function (m) {
        sendOut (m.data);
    }
}

function sendOut (m) {
    output.innerHTML += '<br /> ' + (m);
}

window.callWorker = main;

输出:

select ID, Name from Employee

问题是我需要在水平线上输出此输出,如下所示:

1  Steve
2  Koka
3  Putin 
4  Barack 

1 个答案:

答案 0 :(得分:0)

对于MS SQL,请尝试以下操作:

select [1],[2],[3],[4] 
from (select * from Empolyee) p 
pivot (max(Name) 
for ID in([1],[2],[3],[4])
) as pvt