第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

SQLServer:列到行

SQLServer:列到行

慕仙森 2019-06-25 14:38:35
SQLServer:列到行尋找優(yōu)雅的(或任何)解決方案,將列轉(zhuǎn)換為行。下面是一個(gè)示例:我有一個(gè)具有以下模式的表:[ID] [EntityID] [Indicator1] [Indicator2] [Indicator3] ... [Indicator150]以下是我想得到的結(jié)果:[ID] [EntityId] [IndicatorName] [IndicatorValue]其結(jié)果值為:1 1 'Indicator1' 'Value of Indicator 1 for entity 1'2 1 'Indicator2' 'Value of Indicator 2 for entity 1'3 1 'Indicator3' 'Value of Indicator  3 for entity 1'4 2 'Indicator1' 'Value of Indicator 1 for entity 2'等等。這有道理嗎?對(duì)于在哪里查找和如何在T-SQL中完成任務(wù),您有什么建議嗎?
查看完整描述

3 回答

?
紫衣仙女

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個(gè)贊

為了幫助新的讀者,我創(chuàng)造了一個(gè)例子來(lái)更好地理解@藍(lán)圖對(duì)UNPIVOT的回答。

 SELECT id        ,entityId        ,indicatorname        ,indicatorvalue  FROM (VALUES
        (1, 1, 'Value of Indicator 1 for entity 1', 'Value of Indicator 2 for entity 1', 'Value of Indicator 3 for entity 1'),
        (2, 1, 'Value of Indicator 1 for entity 2', 'Value of Indicator 2 for entity 2', 'Value of Indicator 3 for entity 2'),
        (3, 1, 'Value of Indicator 1 for entity 3', 'Value of Indicator 2 for entity 3', 'Value of Indicator 3 for entity 3'),
        (4, 2, 'Value of Indicator 1 for entity 4', 'Value of Indicator 2 for entity 4', 'Value of Indicator 3 for entity 4')
       ) AS Category(ID, EntityId, Indicator1, Indicator2, Indicator3)UNPIVOT(
    indicatorvalue    FOR indicatorname IN (Indicator1, Indicator2, Indicator3)) UNPIV;


查看完整回答
反對(duì) 回復(fù) 2019-06-25
  • 3 回答
  • 0 關(guān)注
  • 497 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)