當前位置:首頁 » 編程語言 » sqlserver列轉行

sqlserver列轉行

發布時間: 2023-03-01 21:31:08

A. sql 列轉行

CREATE TABLE T1(A NUMBER,
b NUMBER,
c NUMBER,
d NUMBER,
e NUMBER);
insert into t1 values(1,2,3,4,5);
select * from t1;
select decode(A,1,'A',null) KEY ,decode(A,1,1,null) VALUE
from t1
union all
select decode(B,2,'B',null),decode(B,2,2,null)
from t1
union all
select decode(C,3,'C',null),decode(C,3,3,null)
from t1
union all
select decode(D,4,'D',null),decode(D,4,4,null)
from t1
union all
select decode(E,5,'E',null),decode(E,5,5,null)
from t1;

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:576
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:867
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:565
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:747
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:667
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:988
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:236
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:96
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:789
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:695