SQL优化旋转表
我需要旋转我的表,所以如果某个字段(ID)获得一些值我需要创建一个列
我做了一个自定义查询:
SELECT
(DT.[Date]) As RecTime ,
(CASE WHEN DT.ID=51 THEN DT.Value END) AS FlowBSU421,
(CASE WHEN DT.ID=77 THEN DT.Value END) AS TimeAuditBSU331,
(CASE WHEN DT.ID=103 THEN DT.Value END) AS NewValBSU311,
(CASE WHEN DT.ID=129 THEN DT.Value END) AS OldValBSU411,
(CASE WHEN DT.ID=155 THEN DT.Value END) AS CodeAlarmBSU311,
(CASE WHEN DT.ID=181 THEN DT.Value END) AS DataAlarmBSU341,
(CASE WHEN DT.ID=207 THEN DT.Value END) AS DataAlarmBSU441,
(CASE WHEN DT.ID=233 THEN DT.Value END) AS AnalizComp1C6plus_vol,
(CASE WHEN DT.ID=259 THEN DT.Value END) AS AnalizComp2C6plus_mol,
(CASE WHEN DT.ID=285 THEN DT.Value END) AS AnalizComp2Abs_ro,
(CASE WHEN DT.ID=311 THEN DT.Value END) AS Inj_Gas2,
(CASE WHEN DT.ID=312 THEN DT.Value END) AS Inj_mainPower,
(CASE WHEN DT.ID=313 THEN DT.Value END) AS Inj_supPower,
(CASE WHEN DT.ID=314 THEN DT.Value END) AS Inj_PowerSFmain,
(CASE WHEN DT.ID=315 THEN DT.Value END) AS Inj_PowerSFres,
(CASE WHEN DT.ID=316 THEN DT.Value END) AS Inj_PowerCPUmain,
(CASE WHEN DT.ID=317 THEN DT.Value END) AS Inj_PowerCPUres,
(CASE WHEN DT.ID=318 THEN DT.Value END) AS Inj_PowerAnalitikMain,
(CASE WHEN DT.ID=319 THEN DT.Value END) AS Inj_PowerAnalitikRes,
(CASE WHEN DT.ID=320 THEN DT.Value END) AS Inj_PowerDIOmain,
(CASE WHEN DT.ID=321 THEN DT.Value END) AS Inj_PowerDIOres,
(CASE WHEN DT.ID=322 THEN DT.Value END) AS Inj_PowerKong,
(CASE WHEN DT.ID=323 THEN DT.Value END) AS Warning,
(CASE WHEN DT.ID=324 THEN DT.Value END) AS Alarm,
(CASE WHEN DT.ID=286 THEN DT.Value END) AS AnalizComp2Rel_ro,
(CASE WHEN DT.ID=287 THEN DT.Value END) AS AnalizComp2Vobbe_Lo,
(CASE WHEN DT.ID=288 THEN DT.Value END) AS AnalizComp2Vobbe_Hi,
(CASE WHEN DT.ID=289 THEN DT.Value END) AS AnalizComp2An_Num,
(CASE WHEN DT.ID=290 THEN DT.Value END) AS AnalizComp2Status,
(CASE WHEN DT.ID=291 THEN DT.Value END) AS AnalizSeraAnDTS,
(CASE WHEN DT.ID=292 THEN DT.Value END) AS AnalizSeraC2H5SH,
(CASE WHEN DT.ID=293 THEN DT.Value END) AS AnalizSeraCH3SH,
(CASE WHEN DT.ID=294 THEN DT.Value END) AS AnalizSeraH2S,
(CASE WHEN DT.ID=295 THEN DT.Value END) AS AnalizSeraSummMerS,
(CASE WHEN DT.ID=296 THEN DT.Value END) AS AnalizSeraSummAllS,
(CASE WHEN DT.ID=297 THEN DT.Value END) AS AnalizSeraAnNum,
(CASE WHEN DT.ID=298 THEN DT.Value END) AS AnalizSeraStatus,
(CASE WHEN DT.ID=299 THEN DT.Value END) AS KongPrimaDP,
(CASE WHEN DT.ID=300 THEN DT.Value END) AS KongPrimaDPCH,
(CASE WHEN DT.ID=301 THEN DT.Value END) AS P,
(CASE WHEN DT.ID=302 THEN DT.Value END) AS T,
(CASE WHEN DT.ID=303 THEN DT.Value END) AS Warn_Fire,
(CASE WHEN DT.ID=304 THEN DT.Value END) AS Fire,
(CASE WHEN DT.ID=305 THEN DT.Value END) AS Inj_Fire,
(CASE WHEN DT.ID=306 THEN DT.Value END) AS Gas11,
(CASE WHEN DT.ID=307 THEN DT.Value END) AS Gas21,
(CASE WHEN DT.ID=308 THEN DT.Value END) AS Inj_Gas1,
(CASE WHEN DT.ID=309 THEN DT.Value END) AS Gas12,
(CASE WHEN DT.ID=310 THEN DT.Value END) AS Gas22,
(CASE WHEN DT.ID=325 THEN DT.Value END) AS Inj_Fan,
(CASE WHEN DT.ID=401 THEN DT.Value END) AS FlowBSU351_F,
(CASE WHEN DT.ID=402 THEN DT.Value END) AS FlowBSU352_F,
(CASE WHEN DT.ID=403 THEN DT.Value END) AS PBSU311_F,
(CASE WHEN DT.ID=404 THEN DT.Value END) AS PBSU312_F,
(CASE WHEN DT.ID=405 THEN DT.Value END) AS PBSU321_F,
(CASE WHEN DT.ID=406 THEN DT.Value END) AS PBSU322_F,
(CASE WHEN DT.ID=407 THEN DT.Value END) AS PBSU331_F,
(CASE WHEN DT.ID=408 THEN DT.Value END) AS PBSU332_F,
(CASE WHEN DT.ID=409 THEN DT.Value END) AS PBSU341_F,
(CASE WHEN DT.ID=410 THEN DT.Value END) AS PBSU342_F,
(CASE WHEN DT.ID=411 THEN DT.Value END) AS PBSU351_F,
(CASE WHEN DT.ID=412 THEN DT.Value END) AS PBSU352_F,
(CASE WHEN DT.ID=413 THEN DT.Value END) AS TBSU311_F,
(CASE WHEN DT.ID=414 THEN DT.Value END) AS TBSU312_F,
(CASE WHEN DT.ID=415 THEN DT.Value END) AS TBSU321_F,
(CASE WHEN DT.ID=416 THEN DT.Value END) AS TBSU322_F,
(CASE WHEN DT.ID=417 THEN DT.Value END) AS TBSU331_F,
(CASE WHEN DT.ID=418 THEN DT.Value END) AS TBSU332_F,
(CASE WHEN DT.ID=419 THEN DT.Value END) AS TBSU341_F,
(CASE WHEN DT.ID=420 THEN DT.Value END) AS TBSU342_F,
(CASE WHEN DT.ID=421 THEN DT.Value END) AS TBSU351_F,
(CASE WHEN DT.ID=422 THEN DT.Value END) AS TBSU352_F,
(CASE WHEN DT.ID=423 THEN DT.Value END) AS DPBSU411_F,
(CASE WHEN DT.ID=424 THEN DT.Value END) AS DPBSU412_F,
(CASE WHEN DT.ID=425 THEN DT.Value END) AS DPBSU421_F,
(CASE WHEN DT.ID=326 THEN DT.Value END) AS Low_temp,
(CASE WHEN DT.ID=327 THEN DT.Value END) AS IsBSU311_RUN,
(CASE WHEN DT.ID=328 THEN DT.Value END) AS IsBSU312_RUN,
(CASE WHEN DT.ID=329 THEN DT.Value END) AS IsBSU321_RUN,
(CASE WHEN DT.ID=330 THEN DT.Value END) AS IsBSU322_RUN,
(CASE WHEN DT.ID=331 THEN DT.Value END) AS IsBSU331_RUN,
(CASE WHEN DT.ID=332 THEN DT.Value END) AS IsBSU332_RUN,
(CASE WHEN DT.ID=333 THEN DT.Value END) AS IsBSU341_RUN,
(CASE WHEN DT.ID=334 THEN DT.Value END) AS IsBSU342_RUN,
(CASE WHEN DT.ID=335 THEN DT.Value END) AS IsBSU351_RUN,
(CASE WHEN DT.ID=336 THEN DT.Value END) AS IsBSU352_RUN,
(CASE WHEN DT.ID=337 THEN DT.Value END) AS IsBSU411_RUN,
(CASE WHEN DT.ID=338 THEN DT.Value END) AS IsBSU412_RUN,
(CASE WHEN DT.ID=339 THEN DT.Value END) AS IsBSU421_RUN,
(CASE WHEN DT.ID=340 THEN DT.Value END) AS IsBSU422_RUN,
(CASE WHEN DT.ID=341 THEN DT.Value END) AS IsBSU431_RUN,
(CASE WHEN DT.ID=342 THEN DT.Value END) AS IsBSU432_RUN,
(CASE WHEN DT.ID=343 THEN DT.Value END) AS IsBSU441_RUN,
(CASE WHEN DT.ID=344 THEN DT.Value END) AS IsBSU442_RUN,
(CASE WHEN DT.ID=345 THEN DT.Value END) AS IsKongPrimaOn,
(CASE WHEN DT.ID=346 THEN DT.Value END) AS SauGISLinkQuality,
(CASE WHEN DT.ID=347 THEN DT.Value END) AS K42OPEN,
(CASE WHEN DT.ID=348 THEN DT.Value END) AS K42CLOSE,
(CASE WHEN DT.ID=349 THEN DT.Value END) AS K44OPEN,
(CASE WHEN DT.ID=350 THEN DT.Value END) AS K44CLOSE,
(CASE WHEN DT.ID=351 THEN DT.Value END) AS K46OPEN,
(CASE WHEN DT.ID=352 THEN DT.Value END) AS K46CLOSE,
(CASE WHEN DT.ID=353 THEN DT.Value END) AS K424OPEN,
(CASE WHEN DT.ID=354 THEN DT.Value END) AS K424CLOSE,
(CASE WHEN DT.ID=355 THEN DT.Value END) AS K420OPEN,
(CASE WHEN DT.ID=356 THEN DT.Value END) AS K420CLOSE,
(CASE WHEN DT.ID=357 THEN DT.Value END) AS K13OPEN,
(CASE WHEN DT.ID=358 THEN DT.Value END) AS K13CLOSE,
(CASE WHEN DT.ID=359 THEN DT.Value END) AS K33OPEN,
(CASE WHEN DT.ID=360 THEN DT.Value END) AS K33CLOSE,
(CASE WHEN DT.ID=361 THEN DT.Value END) AS K34OPEN,
(CASE WHEN DT.ID=362 THEN DT.Value END) AS K34CLOSE,
(CASE WHEN DT.ID=363 THEN DT.Value END) AS K36OPEN,
(CASE WHEN DT.ID=364 THEN DT.Value END) AS K36CLOSE,
(CASE WHEN DT.ID=365 THEN DT.Value END) AS K38OPEN,
(CASE WHEN DT.ID=366 THEN DT.Value END) AS K38CLOSE,
(CASE WHEN DT.ID=367 THEN DT.Value END) AS K330OPEN,
(CASE WHEN DT.ID=368 THEN DT.Value END) AS K330CLOSE,
(CASE WHEN DT.ID=369 THEN DT.Value END) AS K326OPEN,
(CASE WHEN DT.ID=370 THEN DT.Value END) AS K326CLOSE,
(CASE WHEN DT.ID=371 THEN DT.Value END) AS K42FAULT,
(CASE WHEN DT.ID=372 THEN DT.Value END) AS K44FAULT,
(CASE WHEN DT.ID=373 THEN DT.Value END) AS K46FAULT,
(CASE WHEN DT.ID=374 THEN DT.Value END) AS K424FAULT,
(CASE WHEN DT.ID=375 THEN DT.Value END) AS K420FAULT,
(CASE WHEN DT.ID=426 THEN DT.Value END) AS DPBSU422_F,
(CASE WHEN DT.ID=427 THEN DT.Value END) AS DPBSU431_F,
(CASE WHEN DT.ID=428 THEN DT.Value END) AS DPBSU432_F,
(CASE WHEN DT.ID=429 THEN DT.Value END) AS DPBSU441_F,
(CASE WHEN DT.ID=430 THEN DT.Value END) AS DPBSU442_F,
(CASE WHEN DT.ID=431 THEN DT.Value END) AS FlowBSU411_F,
(CASE WHEN DT.ID=432 THEN DT.Value END) AS FlowBSU412_F,
(CASE WHEN DT.ID=433 THEN DT.Value END) AS FlowBSU421_F,
(CASE WHEN DT.ID=434 THEN DT.Value END) AS FlowBSU422_F,
(CASE WHEN DT.ID=435 THEN DT.Value END) AS FlowBSU431_F,
(CASE WHEN DT.ID=436 THEN DT.Value END) AS FlowBSU432_F,
(CASE WHEN DT.ID=437 THEN DT.Value END) AS FlowBSU441_F,
(CASE WHEN DT.ID=438 THEN DT.Value END) AS FlowBSU442_F,
(CASE WHEN DT.ID=439 THEN DT.Value END) AS PBSU411_F,
(CASE WHEN DT.ID=440 THEN DT.Value END) AS PBSU412_F,
(CASE WHEN DT.ID=441 THEN DT.Value END) AS PBSU421_F,
(CASE WHEN DT.ID=442 THEN DT.Value END) AS PBSU422_F,
(CASE WHEN DT.ID=443 THEN DT.Value END) AS PBSU431_F,
(CASE WHEN DT.ID=444 THEN DT.Value END) AS PBSU432_F,
(CASE WHEN DT.ID=445 THEN DT.Value END) AS PBSU441_F,
(CASE WHEN DT.ID=446 THEN DT.Value END) AS PBSU442_F,
(CASE WHEN DT.ID=447 THEN DT.Value END) AS TBSU411_F,
(CASE WHEN DT.ID=448 THEN DT.Value END) AS TBSU412_F,
(CASE WHEN DT.ID=449 THEN DT.Value END) AS TBSU421_F,
(CASE WHEN DT.ID=450 THEN DT.Value END) AS TBSU422_F,
(CASE WHEN DT.ID=451 THEN DT.Value END) AS TBSU431_F,
(CASE WHEN DT.ID=452 THEN DT.Value END) AS TBSU432_F,
(CASE WHEN DT.ID=453 THEN DT.Value END) AS TBSU441_F,
(CASE WHEN DT.ID=454 THEN DT.Value END) AS TBSU442_F,
(CASE WHEN DT.ID=455 THEN DT.Value END) AS CAM1,
(CASE WHEN DT.ID=456 THEN DT.Value END) AS CAM2,
(CASE WHEN DT.ID=457 THEN DT.Value END) AS CAM3,
(CASE WHEN DT.ID=458 THEN DT.Value END) AS CAM4,
(CASE WHEN DT.ID=459 THEN DT.Value END) AS CAM5,
(CASE WHEN DT.ID=460 THEN DT.Value END) AS CurUser,
(CASE WHEN DT.ID=461 THEN DT.Value END) AS HART311_FAULT,
(CASE WHEN DT.ID=462 THEN DT.Value END) AS HART312_FAULT,
(CASE WHEN DT.ID=463 THEN DT.Value END) AS HART321_FAULT,
(CASE WHEN DT.ID=464 THEN DT.Value END) AS HART322_FAULT,
(CASE WHEN DT.ID=465 THEN DT.Value END) AS HART331_FAULT,
(CASE WHEN DT.ID=466 THEN DT.Value END) AS HART332_FAULT,
(CASE WHEN DT.ID=467 THEN DT.Value END) AS HART341_FAULT,
(CASE WHEN DT.ID=468 THEN DT.Value END) AS HART342_FAULT,
(CASE WHEN DT.ID=469 THEN DT.Value END) AS HART351_FAULT,
(CASE WHEN DT.ID=470 THEN DT.Value END) AS HART352_FAULT,
(CASE WHEN DT.ID=471 THEN DT.Value END) AS HART411_FAULT,
(CASE WHEN DT.ID=472 THEN DT.Value END) AS HART412_FAULT,
(CASE WHEN DT.ID=473 THEN DT.Value END) AS HART421_FAULT,
(CASE WHEN DT.ID=474 THEN DT.Value END) AS HART422_FAULT,
(CASE WHEN DT.ID=475 THEN DT.Value END) AS HART431_FAULT,
(CASE WHEN DT.ID=376 THEN DT.Value END) AS K13FAULT,
(CASE WHEN DT.ID=377 THEN DT.Value END) AS K33FAULT,
(CASE WHEN DT.ID=378 THEN DT.Value END) AS K34FAULT,
(CASE WHEN DT.ID=379 THEN DT.Value END) AS K36FAULT,
(CASE WHEN DT.ID=380 THEN DT.Value END) AS K38FAULT,
(CASE WHEN DT.ID=381 THEN DT.Value END) AS K330FAULT,
(CASE WHEN DT.ID=382 THEN DT.Value END) AS K326FAULT,
(CASE WHEN DT.ID=383 THEN DT.Value END) AS DPBSU311_F,
(CASE WHEN DT.ID=384 THEN DT.Value END) AS DPBSU312_F,
(CASE WHEN DT.ID=385 THEN DT.Value END) AS DPBSU321_F,
(CASE WHEN DT.ID=386 THEN DT.Value END) AS DPBSU322_F,
(CASE WHEN DT.ID=387 THEN DT.Value END) AS DPBSU331_F,
(CASE WHEN DT.ID=388 THEN DT.Value END) AS DPBSU332_F,
(CASE WHEN DT.ID=389 THEN DT.Value END) AS DPBSU341_F,
(CASE WHEN DT.ID=390 THEN DT.Value END) AS DPBSU342_F,
(CASE WHEN DT.ID=391 THEN DT.Value END) AS DPBSU351_F,
(CASE WHEN DT.ID=392 THEN DT.Value END) AS DPBSU352_F,
(CASE WHEN DT.ID=393 THEN DT.Value END) AS FlowBSU311_F,
(CASE WHEN DT.ID=394 THEN DT.Value END) AS FlowBSU312_F,
(CASE WHEN DT.ID=395 THEN DT.Value END) AS FlowBSU321_F,
(CASE WHEN DT.ID=396 THEN DT.Value END) AS FlowBSU322_F,
(CASE WHEN DT.ID=397 THEN DT.Value END) AS FlowBSU331_F,
(CASE WHEN DT.ID=398 THEN DT.Value END) AS FlowBSU332_F,
(CASE WHEN DT.ID=399 THEN DT.Value END) AS FlowBSU341_F,
(CASE WHEN DT.ID=400 THEN DT.Value END) AS FlowBSU342_F,
(CASE WHEN DT.ID=476 THEN DT.Value END) AS HART432_FAULT,
(CASE WHEN DT.ID=477 THEN DT.Value END) AS HART441_FAULT,
(CASE WHEN DT.ID=478 THEN DT.Value END) AS HART442_FAULT,
(CASE WHEN DT.ID=26 THEN DT.Value END) AS PBSU332,
(CASE WHEN DT.ID=27 THEN DT.Value END) AS PBSU341,
(CASE WHEN DT.ID=28 THEN DT.Value END) AS PBSU342,
(CASE WHEN DT.ID=29 THEN DT.Value END) AS PBSU351,
(CASE WHEN DT.ID=30 THEN DT.Value END) AS PBSU352,
(CASE WHEN DT.ID=31 THEN DT.Value END) AS TBSU311,
(CASE WHEN DT.ID=32 THEN DT.Value END) AS TBSU312,
(CASE WHEN DT.ID=33 THEN DT.Value END) AS TBSU321,
(CASE WHEN DT.ID=34 THEN DT.Value END) AS TBSU322,
(CASE WHEN DT.ID=35 THEN DT.Value END) AS TBSU331,
(CASE WHEN DT.ID=36 THEN DT.Value END) AS TBSU332,
(CASE WHEN DT.ID=37 THEN DT.Value END) AS TBSU341,
(CASE WHEN DT.ID=38 THEN DT.Value END) AS TBSU342,
(CASE WHEN DT.ID=39 THEN DT.Value END) AS TBSU351,
(CASE WHEN DT.ID=40 THEN DT.Value END) AS TBSU352,
(CASE WHEN DT.ID=41 THEN DT.Value END) AS DPBSU411,
(CASE WHEN DT.ID=42 THEN DT.Value END) AS DPBSU412,
(CASE WHEN DT.ID=43 THEN DT.Value END) AS DPBSU421,
(CASE WHEN DT.ID=44 THEN DT.Value END) AS DPBSU422,
(CASE WHEN DT.ID=45 THEN DT.Value END) AS DPBSU431,
(CASE WHEN DT.ID=46 THEN DT.Value END) AS DPBSU432,
(CASE WHEN DT.ID=47 THEN DT.Value END) AS DPBSU441,
(CASE WHEN DT.ID=48 THEN DT.Value END) AS DPBSU442,
(CASE WHEN DT.ID=49 THEN DT.Value END) AS FlowBSU411,
(CASE WHEN DT.ID=50 THEN DT.Value END) AS FlowBSU412,
(CASE WHEN DT.ID=52 THEN DT.Value END) AS FlowBSU422,
(CASE WHEN DT.ID=53 THEN DT.Value END) AS FlowBSU431,
(CASE WHEN DT.ID=54 THEN DT.Value END) AS FlowBSU432,
(CASE WHEN DT.ID=55 THEN DT.Value END) AS FlowBSU441,
(CASE WHEN DT.ID=56 THEN DT.Value END) AS FlowBSU442,
(CASE WHEN DT.ID=57 THEN DT.Value END) AS PBSU411,
(CASE WHEN DT.ID=58 THEN DT.Value END) AS PBSU412,
(CASE WHEN DT.ID=59 THEN DT.Value END) AS PBSU421,
(CASE WHEN DT.ID=60 THEN DT.Value END) AS PBSU422,
(CASE WHEN DT.ID=61 THEN DT.Value END) AS PBSU431,
(CASE WHEN DT.ID=62 THEN DT.Value END) AS PBSU432,
(CASE WHEN DT.ID=63 THEN DT.Value END) AS PBSU441,
(CASE WHEN DT.ID=64 THEN DT.Value END) AS PBSU442,
(CASE WHEN DT.ID=65 THEN DT.Value END) AS TBSU411,
(CASE WHEN DT.ID=66 THEN DT.Value END) AS TBSU412,
(CASE WHEN DT.ID=67 THEN DT.Value END) AS TBSU421,
(CASE WHEN DT.ID=68 THEN DT.Value END) AS TBSU422,
(CASE WHEN DT.ID=69 THEN DT.Value END) AS TBSU431,
(CASE WHEN DT.ID=70 THEN DT.Value END) AS TBSU432,
(CASE WHEN DT.ID=71 THEN DT.Value END) AS TBSU441,
(CASE WHEN DT.ID=72 THEN DT.Value END) AS TBSU442,
(CASE WHEN DT.ID=73 THEN DT.Value END) AS TimeAuditBSU311,
(CASE WHEN DT.ID=74 THEN DT.Value END) AS TimeAuditBSU312,
(CASE WHEN DT.ID=75 THEN DT.Value END) AS TimeAuditBSU321,
(CASE WHEN DT.ID=76 THEN DT.Value END) AS TimeAuditBSU322,
(CASE WHEN DT.ID=78 THEN DT.Value END) AS TimeAuditBSU332,
(CASE WHEN DT.ID=79 THEN DT.Value END) AS TimeAuditBSU341,
(CASE WHEN DT.ID=80 THEN DT.Value END) AS TimeAuditBSU342,
(CASE WHEN DT.ID=81 THEN DT.Value END) AS TimeAuditBSU351,
(CASE WHEN DT.ID=82 THEN DT.Value END) AS TimeAuditBSU352,
(CASE WHEN DT.ID=83 THEN DT.Value END) AS ParAuditBSU311,
(CASE WHEN DT.ID=84 THEN DT.Value END) AS ParAuditBSU312,
(CASE WHEN DT.ID=85 THEN DT.Value END) AS ParAuditBSU321,
(CASE WHEN DT.ID=86 THEN DT.Value END) AS ParAuditBSU322,
(CASE WHEN DT.ID=87 THEN DT.Value END) AS ParAuditBSU331,
(CASE WHEN DT.ID=88 THEN DT.Value END) AS ParAuditBSU332,
(CASE WHEN DT.ID=89 THEN DT.Value END) AS ParAuditBSU341,
(CASE WHEN DT.ID=90 THEN DT.Value END) AS ParAuditBSU342,
(CASE WHEN DT.ID=91 THEN DT.Value END) AS ParAuditBSU351,
(CASE WHEN DT.ID=92 THEN DT.Value END) AS ParAuditBSU352,
(CASE WHEN DT.ID=93 THEN DT.Value END) AS OldValBSU311,
(CASE WHEN DT.ID=94 THEN DT.Value END) AS OldValBSU312,
(CASE WHEN DT.ID=95 THEN DT.Value END) AS OldValBSU321,
(CASE WHEN DT.ID=96 THEN DT.Value END) AS OldValBSU322,
(CASE WHEN DT.ID=97 THEN DT.Value END) AS OldValBSU331,
(CASE WHEN DT.ID=98 THEN DT.Value END) AS OldValBSU332,
(CASE WHEN DT.ID=99 THEN DT.Value END) AS OldValBSU341,
(CASE WHEN DT.ID=100 THEN DT.Value END) AS OldValBSU342,
(CASE WHEN DT.ID=101 THEN DT.Value END) AS OldValBSU351,
(CASE WHEN DT.ID=102 THEN DT.Value END) AS OldValBSU352,
(CASE WHEN DT.ID=2 THEN DT.Value END) AS DPBSU312,
(CASE WHEN DT.ID=3 THEN DT.Value END) AS DPBSU321,
(CASE WHEN DT.ID=4 THEN DT.Value END) AS DPBSU322,
(CASE WHEN DT.ID=5 THEN DT.Value END) AS DPBSU331,
(CASE WHEN DT.ID=6 THEN DT.Value END) AS DPBSU332,
(CASE WHEN DT.ID=7 THEN DT.Value END) AS DPBSU341,
(CASE WHEN DT.ID=8 THEN DT.Value END) AS DPBSU342,
(CASE WHEN DT.ID=9 THEN DT.Value END) AS DPBSU351,
(CASE WHEN DT.ID=10 THEN DT.Value END) AS DPBSU352,
(CASE WHEN DT.ID=11 THEN DT.Value END) AS FlowBSU311,
(CASE WHEN DT.ID=12 THEN DT.Value END) AS FlowBSU312,
(CASE WHEN DT.ID=13 THEN DT.Value END) AS FlowBSU321,
(CASE WHEN DT.ID=14 THEN DT.Value END) AS FlowBSU322,
(CASE WHEN DT.ID=15 THEN DT.Value END) AS FlowBSU331,
(CASE WHEN DT.ID=16 THEN DT.Value END) AS FlowBSU332,
(CASE WHEN DT.ID=17 THEN DT.Value END) AS FlowBSU341,
(CASE WHEN DT.ID=18 THEN DT.Value END) AS FlowBSU342,
(CASE WHEN DT.ID=19 THEN DT.Value END) AS FlowBSU351,
(CASE WHEN DT.ID=20 THEN DT.Value END) AS FlowBSU352,
(CASE WHEN DT.ID=21 THEN DT.Value END) AS PBSU311,
(CASE WHEN DT.ID=22 THEN DT.Value END) AS PBSU312,
(CASE WHEN DT.ID=23 THEN DT.Value END) AS PBSU321,
(CASE WHEN DT.ID=24 THEN DT.Value END) AS PBSU322,
(CASE WHEN DT.ID=104 THEN DT.Value END) AS NewValBSU312,
(CASE WHEN DT.ID=105 THEN DT.Value END) AS NewValBSU321,
(CASE WHEN DT.ID=106 THEN DT.Value END) AS NewValBSU322,
(CASE WHEN DT.ID=107 THEN DT.Value END) AS NewValBSU331,
(CASE WHEN DT.ID=108 THEN DT.Value END) AS NewValBSU332,
(CASE WHEN DT.ID=109 THEN DT.Value END) AS NewValBSU341,
(CASE WHEN DT.ID=110 THEN DT.Value END) AS NewValBSU342,
(CASE WHEN DT.ID=111 THEN DT.Value END) AS NewValBSU351,
(CASE WHEN DT.ID=112 THEN DT.Value END) AS NewValBSU352,
(CASE WHEN DT.ID=113 THEN DT.Value END) AS TimeAuditBSU411,
(CASE WHEN DT.ID=114 THEN DT.Value END) AS TimeAuditBSU412,
(CASE WHEN DT.ID=115 THEN DT.Value END) AS TimeAuditBSU421,
(CASE WHEN DT.ID=116 THEN DT.Value END) AS TimeAuditBSU422,
(CASE WHEN DT.ID=117 THEN DT.Value END) AS TimeAuditBSU431,
(CASE WHEN DT.ID=118 THEN DT.Value END) AS TimeAuditBSU432,
(CASE WHEN DT.ID=119 THEN DT.Value END) AS TimeAuditBSU441,
(CASE WHEN DT.ID=120 THEN DT.Value END) AS TimeAuditBSU442,
(CASE WHEN DT.ID=121 THEN DT.Value END) AS ParAuditBSU411,
(CASE WHEN DT.ID=122 THEN DT.Value END) AS ParAuditBSU412,
(CASE WHEN DT.ID=123 THEN DT.Value END) AS ParAuditBSU421,
(CASE WHEN DT.ID=124 THEN DT.Value END) AS ParAuditBSU422,
(CASE WHEN DT.ID=125 THEN DT.Value END) AS ParAuditBSU431,
(CASE WHEN DT.ID=126 THEN DT.Value END) AS ParAuditBSU432,
(CASE WHEN DT.ID=127 THEN DT.Value END) AS ParAuditBSU441,
(CASE WHEN DT.ID=128 THEN DT.Value END) AS ParAuditBSU442,
(CASE WHEN DT.ID=130 THEN DT.Value END) AS OldValBSU412,
(CASE WHEN DT.ID=131 THEN DT.Value END) AS OldValBSU421,
(CASE WHEN DT.ID=132 THEN DT.Value END) AS OldValBSU422,
(CASE WHEN DT.ID=133 THEN DT.Value END) AS OldValBSU431,
(CASE WHEN DT.ID=134 THEN DT.Value END) AS OldValBSU432,
(CASE WHEN DT.ID=135 THEN DT.Value END) AS OldValBSU441,
(CASE WHEN DT.ID=136 THEN DT.Value END) AS OldValBSU442,
(CASE WHEN DT.ID=137 THEN DT.Value END) AS NewValBSU411,
(CASE WHEN DT.ID=138 THEN DT.Value END) AS NewValBSU412,
(CASE WHEN DT.ID=139 THEN DT.Value END) AS NewValBSU421,
(CASE WHEN DT.ID=140 THEN DT.Value END) AS NewValBSU422,
(CASE WHEN DT.ID=141 THEN DT.Value END) AS NewValBSU431,
(CASE WHEN DT.ID=142 THEN DT.Value END) AS NewValBSU432,
(CASE WHEN DT.ID=143 THEN DT.Value END) AS NewValBSU441,
(CASE WHEN DT.ID=144 THEN DT.Value END) AS NewValBSU442,
(CASE WHEN DT.ID=145 THEN DT.Value END) AS TimeAlarmBSU311,
(CASE WHEN DT.ID=146 THEN DT.Value END) AS TimeAlarmBSU312,
(CASE WHEN DT.ID=147 THEN DT.Value END) AS TimeAlarmBSU321,
(CASE WHEN DT.ID=148 THEN DT.Value END) AS TimeAlarmBSU322,
(CASE WHEN DT.ID=149 THEN DT.Value END) AS TimeAlarmBSU331,
(CASE WHEN DT.ID=150 THEN DT.Value END) AS TimeAlarmBSU332,
(CASE WHEN DT.ID=151 THEN DT.Value END) AS TimeAlarmBSU341,
(CASE WHEN DT.ID=152 THEN DT.Value END) AS TimeAlarmBSU342,
(CASE WHEN DT.ID=153 THEN DT.Value END) AS TimeAlarmBSU351,
(CASE WHEN DT.ID=154 THEN DT.Value END) AS TimeAlarmBSU352,
(CASE WHEN DT.ID=156 THEN DT.Value END) AS CodeAlarmBSU312,
(CASE WHEN DT.ID=157 THEN DT.Value END) AS CodeAlarmBSU321,
(CASE WHEN DT.ID=158 THEN DT.Value END) AS CodeAlarmBSU322,
(CASE WHEN DT.ID=159 THEN DT.Value END) AS CodeAlarmBSU331,
(CASE WHEN DT.ID=160 THEN DT.Value END) AS CodeAlarmBSU332,
(CASE WHEN DT.ID=161 THEN DT.Value END) AS CodeAlarmBSU341,
(CASE WHEN DT.ID=162 THEN DT.Value END) AS CodeAlarmBSU342,
(CASE WHEN DT.ID=163 THEN DT.Value END) AS CodeAlarmBSU351,
(CASE WHEN DT.ID=164 THEN DT.Value END) AS CodeAlarmBSU352,
(CASE WHEN DT.ID=165 THEN DT.Value END) AS PointAlarmBSU311,
(CASE WHEN DT.ID=166 THEN DT.Value END) AS PointAlarmBSU312,
(CASE WHEN DT.ID=167 THEN DT.Value END) AS PointAlarmBSU321,
(CASE WHEN DT.ID=168 THEN DT.Value END) AS PointAlarmBSU322,
(CASE WHEN DT.ID=169 THEN DT.Value END) AS PointAlarmBSU331,
(CASE WHEN DT.ID=170 THEN DT.Value END) AS PointAlarmBSU332,
(CASE WHEN DT.ID=171 THEN DT.Value END) AS PointAlarmBSU341,
(CASE WHEN DT.ID=172 THEN DT.Value END) AS PointAlarmBSU342,
(CASE WHEN DT.ID=173 THEN DT.Value END) AS PointAlarmBSU351,
(CASE WHEN DT.ID=174 THEN DT.Value END) AS PointAlarmBSU352,
(CASE WHEN DT.ID=175 THEN DT.Value END) AS DataAlarmBSU311,
(CASE WHEN DT.ID=176 THEN DT.Value END) AS DataAlarmBSU312,
(CASE WHEN DT.ID=177 THEN DT.Value END) AS DataAlarmBSU321,
(CASE WHEN DT.ID=178 THEN DT.Value END) AS DataAlarmBSU322,
(CASE WHEN DT.ID=179 THEN DT.Value END) AS DataAlarmBSU331,
(CASE WHEN DT.ID=180 THEN DT.Value END) AS DataAlarmBSU332,
(CASE WHEN DT.ID=182 THEN DT.Value END) AS DataAlarmBSU342,
(CASE WHEN DT.ID=183 THEN DT.Value END) AS DataAlarmBSU351,
(CASE WHEN DT.ID=184 THEN DT.Value END) AS DataAlarmBSU352,
(CASE WHEN DT.ID=185 THEN DT.Value END) AS CodeAlarmBSU411,
(CASE WHEN DT.ID=186 THEN DT.Value END) AS CodeAlarmBSU412,
(CASE WHEN DT.ID=187 THEN DT.Value END) AS CodeAlarmBSU421,
(CASE WHEN DT.ID=188 THEN DT.Value END) AS CodeAlarmBSU422,
(CASE WHEN DT.ID=189 THEN DT.Value END) AS CodeAlarmBSU423,
(CASE WHEN DT.ID=190 THEN DT.Value END) AS CodeAlarmBSU424,
(CASE WHEN DT.ID=191 THEN DT.Value END) AS CodeAlarmBSU441,
(CASE WHEN DT.ID=192 THEN DT.Value END) AS CodeAlarmBSU442,
(CASE WHEN DT.ID=193 THEN DT.Value END) AS PointAlarmBSU411,
(CASE WHEN DT.ID=194 THEN DT.Value END) AS PointAlarmBSU412,
(CASE WHEN DT.ID=195 THEN DT.Value END) AS PointAlarmBSU421,
(CASE WHEN DT.ID=196 THEN DT.Value END) AS PointAlarmBSU422,
(CASE WHEN DT.ID=197 THEN DT.Value END) AS PointAlarmBSU431,
(CASE WHEN DT.ID=198 THEN DT.Value END) AS PointAlarmBSU432,
(CASE WHEN DT.ID=199 THEN DT.Value END) AS PointAlarmBSU441,
(CASE WHEN DT.ID=200 THEN DT.Value END) AS PointAlarmBSU442,
(CASE WHEN DT.ID=201 THEN DT.Value END) AS DataAlarmBSU411,
(CASE WHEN DT.ID=202 THEN DT.Value END) AS DataAlarmBSU412,
(CASE WHEN DT.ID=203 THEN DT.Value END) AS DataAlarmBSU421,
(CASE WHEN DT.ID=204 THEN DT.Value END) AS DataAlarmBSU422,
(CASE WHEN DT.ID=205 THEN DT.Value END) AS DataAlarmBSU431,
(CASE WHEN DT.ID=206 THEN DT.Value END) AS DataAlarmBSU432,
(CASE WHEN DT.ID=208 THEN DT.Value END) AS DataAlarmBSU442,
(CASE WHEN DT.ID=209 THEN DT.Value END) AS AnalizComp1An_DT1,
(CASE WHEN DT.ID=210 THEN DT.Value END) AS AnalizComp1CH4_mol,
(CASE WHEN DT.ID=211 THEN DT.Value END) AS AnalizComp1C2H6_mol,
(CASE WHEN DT.ID=212 THEN DT.Value END) AS AnalizComp1C3H8_mol,
(CASE WHEN DT.ID=213 THEN DT.Value END) AS AnalizComp1iC4H10_mol,
(CASE WHEN DT.ID=214 THEN DT.Value END) AS AnalizComp1nC4H10_mol,
(CASE WHEN DT.ID=215 THEN DT.Value END) AS AnalizComp1neoC5H12_mol,
(CASE WHEN DT.ID=216 THEN DT.Value END) AS AnalizComp1iC5H12_mol,
(CASE WHEN DT.ID=217 THEN DT.Value END) AS AnalizComp1nC5H12_mol,
(CASE WHEN DT.ID=218 THEN DT.Value END) AS AnalizComp1C6plus_mol,
(CASE WHEN DT.ID=219 THEN DT.Value END) AS AnalizComp1N2_mol,
(CASE WHEN DT.ID=220 THEN DT.Value END) AS AnalizComp1O2_mol,
(CASE WHEN DT.ID=221 THEN DT.Value END) AS AnalizComp1CO2_mol,
(CASE WHEN DT.ID=222 THEN DT.Value END) AS AnalizComp1He_mol,
(CASE WHEN DT.ID=223 THEN DT.Value END) AS AnalizComp1H_mol,
(CASE WHEN DT.ID=224 THEN DT.Value END) AS AnalizComp1H2O_mol,
(CASE WHEN DT.ID=225 THEN DT.Value END) AS AnalizComp1CH4_vol,
(CASE WHEN DT.ID=226 THEN DT.Value END) AS AnalizComp1C2H6_vol,
(CASE WHEN DT.ID=227 THEN DT.Value END) AS AnalizComp1C3H8_vol,
(CASE WHEN DT.ID=228 THEN DT.Value END) AS AnalizComp1iC4H10_vol,
(CASE WHEN DT.ID=229 THEN DT.Value END) AS AnalizComp1nC4H10_vol,
(CASE WHEN DT.ID=230 THEN DT.Value END) AS AnalizComp1neoC5H12_vol,
(CASE WHEN DT.ID=231 THEN DT.Value END) AS AnalizComp1iC5H12_vol,
(CASE WHEN DT.ID=232 THEN DT.Value END) AS AnalizComp1nC5H12_vol,
(CASE WHEN DT.ID=234 THEN DT.Value END) AS AnalizComp1N2_vol,
(CASE WHEN DT.ID=235 THEN DT.Value END) AS AnalizComp1O2_vol,
(CASE WHEN DT.ID=236 THEN DT.Value END) AS AnalizComp1CO2_vol,
(CASE WHEN DT.ID=237 THEN DT.Value END) AS AnalizComp1He_vol,
(CASE WHEN DT.ID=238 THEN DT.Value END) AS AnalizComp1H_vol,
(CASE WHEN DT.ID=239 THEN DT.Value END) AS AnalizComp1H2O_vol,
(CASE WHEN DT.ID=240 THEN DT.Value END) AS AnalizComp1Koeff,
(CASE WHEN DT.ID=241 THEN DT.Value END) AS AnalizComp1Mol_Mass,
(CASE WHEN DT.ID=242 THEN DT.Value END) AS AnalizComp1UTS_Lo,
(CASE WHEN DT.ID=243 THEN DT.Value END) AS AnalizComp1UTS_Hi,
(CASE WHEN DT.ID=244 THEN DT.Value END) AS AnalizComp1Abs_ro,
(CASE WHEN DT.ID=245 THEN DT.Value END) AS AnalizComp1Rel_ro,
(CASE WHEN DT.ID=246 THEN DT.Value END) AS AnalizComp1Vobbe_Lo,
(CASE WHEN DT.ID=247 THEN DT.Value END) AS AnalizComp1Vobbe_Hi,
(CASE WHEN DT.ID=248 THEN DT.Value END) AS AnalizComp1An_Num,
(CASE WHEN DT.ID=249 THEN DT.Value END) AS AnalizComp1Status,
(CASE WHEN DT.ID=250 THEN DT.Value END) AS AnalizComp2An_DT1,
(CASE WHEN DT.ID=251 THEN DT.Value END) AS AnalizComp2CH4_mol,
(CASE WHEN DT.ID=252 THEN DT.Value END) AS AnalizComp2C2H6_mol,
(CASE WHEN DT.ID=253 THEN DT.Value END) AS AnalizComp2C3H8_mol,
(CASE WHEN DT.ID=254 THEN DT.Value END) AS AnalizComp2iC4H10_mol,
(CASE WHEN DT.ID=255 THEN DT.Value END) AS AnalizComp2nC4H10_mol,
(CASE WHEN DT.ID=256 THEN DT.Value END) AS AnalizComp2neoC5H12_mol,
(CASE WHEN DT.ID=257 THEN DT.Value END) AS AnalizComp2iC5H12_mol,
(CASE WHEN DT.ID=258 THEN DT.Value END) AS AnalizComp2nC5H12_mol,
(CASE WHEN DT.ID=260 THEN DT.Value END) AS AnalizComp2N2_mol,
(CASE WHEN DT.ID=261 THEN DT.Value END) AS AnalizComp2O2_mol,
(CASE WHEN DT.ID=262 THEN DT.Value END) AS AnalizComp2CO2_mol,
(CASE WHEN DT.ID=263 THEN DT.Value END) AS AnalizComp2He_mol,
(CASE WHEN DT.ID=264 THEN DT.Value END) AS AnalizComp2H_mol,
(CASE WHEN DT.ID=265 THEN DT.Value END) AS AnalizComp2H2O_mol,
(CASE WHEN DT.ID=266 THEN DT.Value END) AS AnalizComp2CH4_vol,
(CASE WHEN DT.ID=267 THEN DT.Value END) AS AnalizComp2C2H6_vol,
(CASE WHEN DT.ID=268 THEN DT.Value END) AS AnalizComp2C3H8_vol,
(CASE WHEN DT.ID=269 THEN DT.Value END) AS AnalizComp2iC4H10_vol,
(CASE WHEN DT.ID=270 THEN DT.Value END) AS AnalizComp2nC4H10_vol,
(CASE WHEN DT.ID=271 THEN DT.Value END) AS AnalizComp2neoC5H12_vol,
(CASE WHEN DT.ID=272 THEN DT.Value END) AS AnalizComp2iC5H12_vol,
(CASE WHEN DT.ID=273 THEN DT.Value END) AS AnalizComp2nC5H12_vol,
(CASE WHEN DT.ID=274 THEN DT.Value END) AS AnalizComp2C6plus_vol,
(CASE WHEN DT.ID=275 THEN DT.Value END) AS AnalizComp2N2_vol,
(CASE WHEN DT.ID=276 THEN DT.Value END) AS AnalizComp2O2_vol,
(CASE WHEN DT.ID=277 THEN DT.Value END) AS AnalizComp2CO2_vol,
(CASE WHEN DT.ID=278 THEN DT.Value END) AS AnalizComp2He_vol,
(CASE WHEN DT.ID=279 THEN DT.Value END) AS AnalizComp2H_vol,
(CASE WHEN DT.ID=280 THEN DT.Value END) AS AnalizComp2H2O_vol,
(CASE WHEN DT.ID=281 THEN DT.Value END) AS AnalizComp2Koeff,
(CASE WHEN DT.ID=282 THEN DT.Value END) AS AnalizComp2Mol_Mass,
(CASE WHEN DT.ID=283 THEN DT.Value END) AS AnalizComp2UTS_Lo,
(CASE WHEN DT.ID=284 THEN DT.Value END) AS AnalizComp2UTS_Hi
FROM
(SELECT [Date],[ID],[Value] FROM [ArchiveAnalog]) AS DT
是的......这应该很有趣,但它的工作速度非常慢。
真的要优化这个吗...?
I need to rotate my table , so I need to make a columns if some field (ID) got some value
I made a custom query :
SELECT
(DT.[Date]) As RecTime ,
(CASE WHEN DT.ID=51 THEN DT.Value END) AS FlowBSU421,
(CASE WHEN DT.ID=77 THEN DT.Value END) AS TimeAuditBSU331,
(CASE WHEN DT.ID=103 THEN DT.Value END) AS NewValBSU311,
(CASE WHEN DT.ID=129 THEN DT.Value END) AS OldValBSU411,
(CASE WHEN DT.ID=155 THEN DT.Value END) AS CodeAlarmBSU311,
(CASE WHEN DT.ID=181 THEN DT.Value END) AS DataAlarmBSU341,
(CASE WHEN DT.ID=207 THEN DT.Value END) AS DataAlarmBSU441,
(CASE WHEN DT.ID=233 THEN DT.Value END) AS AnalizComp1C6plus_vol,
(CASE WHEN DT.ID=259 THEN DT.Value END) AS AnalizComp2C6plus_mol,
(CASE WHEN DT.ID=285 THEN DT.Value END) AS AnalizComp2Abs_ro,
(CASE WHEN DT.ID=311 THEN DT.Value END) AS Inj_Gas2,
(CASE WHEN DT.ID=312 THEN DT.Value END) AS Inj_mainPower,
(CASE WHEN DT.ID=313 THEN DT.Value END) AS Inj_supPower,
(CASE WHEN DT.ID=314 THEN DT.Value END) AS Inj_PowerSFmain,
(CASE WHEN DT.ID=315 THEN DT.Value END) AS Inj_PowerSFres,
(CASE WHEN DT.ID=316 THEN DT.Value END) AS Inj_PowerCPUmain,
(CASE WHEN DT.ID=317 THEN DT.Value END) AS Inj_PowerCPUres,
(CASE WHEN DT.ID=318 THEN DT.Value END) AS Inj_PowerAnalitikMain,
(CASE WHEN DT.ID=319 THEN DT.Value END) AS Inj_PowerAnalitikRes,
(CASE WHEN DT.ID=320 THEN DT.Value END) AS Inj_PowerDIOmain,
(CASE WHEN DT.ID=321 THEN DT.Value END) AS Inj_PowerDIOres,
(CASE WHEN DT.ID=322 THEN DT.Value END) AS Inj_PowerKong,
(CASE WHEN DT.ID=323 THEN DT.Value END) AS Warning,
(CASE WHEN DT.ID=324 THEN DT.Value END) AS Alarm,
(CASE WHEN DT.ID=286 THEN DT.Value END) AS AnalizComp2Rel_ro,
(CASE WHEN DT.ID=287 THEN DT.Value END) AS AnalizComp2Vobbe_Lo,
(CASE WHEN DT.ID=288 THEN DT.Value END) AS AnalizComp2Vobbe_Hi,
(CASE WHEN DT.ID=289 THEN DT.Value END) AS AnalizComp2An_Num,
(CASE WHEN DT.ID=290 THEN DT.Value END) AS AnalizComp2Status,
(CASE WHEN DT.ID=291 THEN DT.Value END) AS AnalizSeraAnDTS,
(CASE WHEN DT.ID=292 THEN DT.Value END) AS AnalizSeraC2H5SH,
(CASE WHEN DT.ID=293 THEN DT.Value END) AS AnalizSeraCH3SH,
(CASE WHEN DT.ID=294 THEN DT.Value END) AS AnalizSeraH2S,
(CASE WHEN DT.ID=295 THEN DT.Value END) AS AnalizSeraSummMerS,
(CASE WHEN DT.ID=296 THEN DT.Value END) AS AnalizSeraSummAllS,
(CASE WHEN DT.ID=297 THEN DT.Value END) AS AnalizSeraAnNum,
(CASE WHEN DT.ID=298 THEN DT.Value END) AS AnalizSeraStatus,
(CASE WHEN DT.ID=299 THEN DT.Value END) AS KongPrimaDP,
(CASE WHEN DT.ID=300 THEN DT.Value END) AS KongPrimaDPCH,
(CASE WHEN DT.ID=301 THEN DT.Value END) AS P,
(CASE WHEN DT.ID=302 THEN DT.Value END) AS T,
(CASE WHEN DT.ID=303 THEN DT.Value END) AS Warn_Fire,
(CASE WHEN DT.ID=304 THEN DT.Value END) AS Fire,
(CASE WHEN DT.ID=305 THEN DT.Value END) AS Inj_Fire,
(CASE WHEN DT.ID=306 THEN DT.Value END) AS Gas11,
(CASE WHEN DT.ID=307 THEN DT.Value END) AS Gas21,
(CASE WHEN DT.ID=308 THEN DT.Value END) AS Inj_Gas1,
(CASE WHEN DT.ID=309 THEN DT.Value END) AS Gas12,
(CASE WHEN DT.ID=310 THEN DT.Value END) AS Gas22,
(CASE WHEN DT.ID=325 THEN DT.Value END) AS Inj_Fan,
(CASE WHEN DT.ID=401 THEN DT.Value END) AS FlowBSU351_F,
(CASE WHEN DT.ID=402 THEN DT.Value END) AS FlowBSU352_F,
(CASE WHEN DT.ID=403 THEN DT.Value END) AS PBSU311_F,
(CASE WHEN DT.ID=404 THEN DT.Value END) AS PBSU312_F,
(CASE WHEN DT.ID=405 THEN DT.Value END) AS PBSU321_F,
(CASE WHEN DT.ID=406 THEN DT.Value END) AS PBSU322_F,
(CASE WHEN DT.ID=407 THEN DT.Value END) AS PBSU331_F,
(CASE WHEN DT.ID=408 THEN DT.Value END) AS PBSU332_F,
(CASE WHEN DT.ID=409 THEN DT.Value END) AS PBSU341_F,
(CASE WHEN DT.ID=410 THEN DT.Value END) AS PBSU342_F,
(CASE WHEN DT.ID=411 THEN DT.Value END) AS PBSU351_F,
(CASE WHEN DT.ID=412 THEN DT.Value END) AS PBSU352_F,
(CASE WHEN DT.ID=413 THEN DT.Value END) AS TBSU311_F,
(CASE WHEN DT.ID=414 THEN DT.Value END) AS TBSU312_F,
(CASE WHEN DT.ID=415 THEN DT.Value END) AS TBSU321_F,
(CASE WHEN DT.ID=416 THEN DT.Value END) AS TBSU322_F,
(CASE WHEN DT.ID=417 THEN DT.Value END) AS TBSU331_F,
(CASE WHEN DT.ID=418 THEN DT.Value END) AS TBSU332_F,
(CASE WHEN DT.ID=419 THEN DT.Value END) AS TBSU341_F,
(CASE WHEN DT.ID=420 THEN DT.Value END) AS TBSU342_F,
(CASE WHEN DT.ID=421 THEN DT.Value END) AS TBSU351_F,
(CASE WHEN DT.ID=422 THEN DT.Value END) AS TBSU352_F,
(CASE WHEN DT.ID=423 THEN DT.Value END) AS DPBSU411_F,
(CASE WHEN DT.ID=424 THEN DT.Value END) AS DPBSU412_F,
(CASE WHEN DT.ID=425 THEN DT.Value END) AS DPBSU421_F,
(CASE WHEN DT.ID=326 THEN DT.Value END) AS Low_temp,
(CASE WHEN DT.ID=327 THEN DT.Value END) AS IsBSU311_RUN,
(CASE WHEN DT.ID=328 THEN DT.Value END) AS IsBSU312_RUN,
(CASE WHEN DT.ID=329 THEN DT.Value END) AS IsBSU321_RUN,
(CASE WHEN DT.ID=330 THEN DT.Value END) AS IsBSU322_RUN,
(CASE WHEN DT.ID=331 THEN DT.Value END) AS IsBSU331_RUN,
(CASE WHEN DT.ID=332 THEN DT.Value END) AS IsBSU332_RUN,
(CASE WHEN DT.ID=333 THEN DT.Value END) AS IsBSU341_RUN,
(CASE WHEN DT.ID=334 THEN DT.Value END) AS IsBSU342_RUN,
(CASE WHEN DT.ID=335 THEN DT.Value END) AS IsBSU351_RUN,
(CASE WHEN DT.ID=336 THEN DT.Value END) AS IsBSU352_RUN,
(CASE WHEN DT.ID=337 THEN DT.Value END) AS IsBSU411_RUN,
(CASE WHEN DT.ID=338 THEN DT.Value END) AS IsBSU412_RUN,
(CASE WHEN DT.ID=339 THEN DT.Value END) AS IsBSU421_RUN,
(CASE WHEN DT.ID=340 THEN DT.Value END) AS IsBSU422_RUN,
(CASE WHEN DT.ID=341 THEN DT.Value END) AS IsBSU431_RUN,
(CASE WHEN DT.ID=342 THEN DT.Value END) AS IsBSU432_RUN,
(CASE WHEN DT.ID=343 THEN DT.Value END) AS IsBSU441_RUN,
(CASE WHEN DT.ID=344 THEN DT.Value END) AS IsBSU442_RUN,
(CASE WHEN DT.ID=345 THEN DT.Value END) AS IsKongPrimaOn,
(CASE WHEN DT.ID=346 THEN DT.Value END) AS SauGISLinkQuality,
(CASE WHEN DT.ID=347 THEN DT.Value END) AS K42OPEN,
(CASE WHEN DT.ID=348 THEN DT.Value END) AS K42CLOSE,
(CASE WHEN DT.ID=349 THEN DT.Value END) AS K44OPEN,
(CASE WHEN DT.ID=350 THEN DT.Value END) AS K44CLOSE,
(CASE WHEN DT.ID=351 THEN DT.Value END) AS K46OPEN,
(CASE WHEN DT.ID=352 THEN DT.Value END) AS K46CLOSE,
(CASE WHEN DT.ID=353 THEN DT.Value END) AS K424OPEN,
(CASE WHEN DT.ID=354 THEN DT.Value END) AS K424CLOSE,
(CASE WHEN DT.ID=355 THEN DT.Value END) AS K420OPEN,
(CASE WHEN DT.ID=356 THEN DT.Value END) AS K420CLOSE,
(CASE WHEN DT.ID=357 THEN DT.Value END) AS K13OPEN,
(CASE WHEN DT.ID=358 THEN DT.Value END) AS K13CLOSE,
(CASE WHEN DT.ID=359 THEN DT.Value END) AS K33OPEN,
(CASE WHEN DT.ID=360 THEN DT.Value END) AS K33CLOSE,
(CASE WHEN DT.ID=361 THEN DT.Value END) AS K34OPEN,
(CASE WHEN DT.ID=362 THEN DT.Value END) AS K34CLOSE,
(CASE WHEN DT.ID=363 THEN DT.Value END) AS K36OPEN,
(CASE WHEN DT.ID=364 THEN DT.Value END) AS K36CLOSE,
(CASE WHEN DT.ID=365 THEN DT.Value END) AS K38OPEN,
(CASE WHEN DT.ID=366 THEN DT.Value END) AS K38CLOSE,
(CASE WHEN DT.ID=367 THEN DT.Value END) AS K330OPEN,
(CASE WHEN DT.ID=368 THEN DT.Value END) AS K330CLOSE,
(CASE WHEN DT.ID=369 THEN DT.Value END) AS K326OPEN,
(CASE WHEN DT.ID=370 THEN DT.Value END) AS K326CLOSE,
(CASE WHEN DT.ID=371 THEN DT.Value END) AS K42FAULT,
(CASE WHEN DT.ID=372 THEN DT.Value END) AS K44FAULT,
(CASE WHEN DT.ID=373 THEN DT.Value END) AS K46FAULT,
(CASE WHEN DT.ID=374 THEN DT.Value END) AS K424FAULT,
(CASE WHEN DT.ID=375 THEN DT.Value END) AS K420FAULT,
(CASE WHEN DT.ID=426 THEN DT.Value END) AS DPBSU422_F,
(CASE WHEN DT.ID=427 THEN DT.Value END) AS DPBSU431_F,
(CASE WHEN DT.ID=428 THEN DT.Value END) AS DPBSU432_F,
(CASE WHEN DT.ID=429 THEN DT.Value END) AS DPBSU441_F,
(CASE WHEN DT.ID=430 THEN DT.Value END) AS DPBSU442_F,
(CASE WHEN DT.ID=431 THEN DT.Value END) AS FlowBSU411_F,
(CASE WHEN DT.ID=432 THEN DT.Value END) AS FlowBSU412_F,
(CASE WHEN DT.ID=433 THEN DT.Value END) AS FlowBSU421_F,
(CASE WHEN DT.ID=434 THEN DT.Value END) AS FlowBSU422_F,
(CASE WHEN DT.ID=435 THEN DT.Value END) AS FlowBSU431_F,
(CASE WHEN DT.ID=436 THEN DT.Value END) AS FlowBSU432_F,
(CASE WHEN DT.ID=437 THEN DT.Value END) AS FlowBSU441_F,
(CASE WHEN DT.ID=438 THEN DT.Value END) AS FlowBSU442_F,
(CASE WHEN DT.ID=439 THEN DT.Value END) AS PBSU411_F,
(CASE WHEN DT.ID=440 THEN DT.Value END) AS PBSU412_F,
(CASE WHEN DT.ID=441 THEN DT.Value END) AS PBSU421_F,
(CASE WHEN DT.ID=442 THEN DT.Value END) AS PBSU422_F,
(CASE WHEN DT.ID=443 THEN DT.Value END) AS PBSU431_F,
(CASE WHEN DT.ID=444 THEN DT.Value END) AS PBSU432_F,
(CASE WHEN DT.ID=445 THEN DT.Value END) AS PBSU441_F,
(CASE WHEN DT.ID=446 THEN DT.Value END) AS PBSU442_F,
(CASE WHEN DT.ID=447 THEN DT.Value END) AS TBSU411_F,
(CASE WHEN DT.ID=448 THEN DT.Value END) AS TBSU412_F,
(CASE WHEN DT.ID=449 THEN DT.Value END) AS TBSU421_F,
(CASE WHEN DT.ID=450 THEN DT.Value END) AS TBSU422_F,
(CASE WHEN DT.ID=451 THEN DT.Value END) AS TBSU431_F,
(CASE WHEN DT.ID=452 THEN DT.Value END) AS TBSU432_F,
(CASE WHEN DT.ID=453 THEN DT.Value END) AS TBSU441_F,
(CASE WHEN DT.ID=454 THEN DT.Value END) AS TBSU442_F,
(CASE WHEN DT.ID=455 THEN DT.Value END) AS CAM1,
(CASE WHEN DT.ID=456 THEN DT.Value END) AS CAM2,
(CASE WHEN DT.ID=457 THEN DT.Value END) AS CAM3,
(CASE WHEN DT.ID=458 THEN DT.Value END) AS CAM4,
(CASE WHEN DT.ID=459 THEN DT.Value END) AS CAM5,
(CASE WHEN DT.ID=460 THEN DT.Value END) AS CurUser,
(CASE WHEN DT.ID=461 THEN DT.Value END) AS HART311_FAULT,
(CASE WHEN DT.ID=462 THEN DT.Value END) AS HART312_FAULT,
(CASE WHEN DT.ID=463 THEN DT.Value END) AS HART321_FAULT,
(CASE WHEN DT.ID=464 THEN DT.Value END) AS HART322_FAULT,
(CASE WHEN DT.ID=465 THEN DT.Value END) AS HART331_FAULT,
(CASE WHEN DT.ID=466 THEN DT.Value END) AS HART332_FAULT,
(CASE WHEN DT.ID=467 THEN DT.Value END) AS HART341_FAULT,
(CASE WHEN DT.ID=468 THEN DT.Value END) AS HART342_FAULT,
(CASE WHEN DT.ID=469 THEN DT.Value END) AS HART351_FAULT,
(CASE WHEN DT.ID=470 THEN DT.Value END) AS HART352_FAULT,
(CASE WHEN DT.ID=471 THEN DT.Value END) AS HART411_FAULT,
(CASE WHEN DT.ID=472 THEN DT.Value END) AS HART412_FAULT,
(CASE WHEN DT.ID=473 THEN DT.Value END) AS HART421_FAULT,
(CASE WHEN DT.ID=474 THEN DT.Value END) AS HART422_FAULT,
(CASE WHEN DT.ID=475 THEN DT.Value END) AS HART431_FAULT,
(CASE WHEN DT.ID=376 THEN DT.Value END) AS K13FAULT,
(CASE WHEN DT.ID=377 THEN DT.Value END) AS K33FAULT,
(CASE WHEN DT.ID=378 THEN DT.Value END) AS K34FAULT,
(CASE WHEN DT.ID=379 THEN DT.Value END) AS K36FAULT,
(CASE WHEN DT.ID=380 THEN DT.Value END) AS K38FAULT,
(CASE WHEN DT.ID=381 THEN DT.Value END) AS K330FAULT,
(CASE WHEN DT.ID=382 THEN DT.Value END) AS K326FAULT,
(CASE WHEN DT.ID=383 THEN DT.Value END) AS DPBSU311_F,
(CASE WHEN DT.ID=384 THEN DT.Value END) AS DPBSU312_F,
(CASE WHEN DT.ID=385 THEN DT.Value END) AS DPBSU321_F,
(CASE WHEN DT.ID=386 THEN DT.Value END) AS DPBSU322_F,
(CASE WHEN DT.ID=387 THEN DT.Value END) AS DPBSU331_F,
(CASE WHEN DT.ID=388 THEN DT.Value END) AS DPBSU332_F,
(CASE WHEN DT.ID=389 THEN DT.Value END) AS DPBSU341_F,
(CASE WHEN DT.ID=390 THEN DT.Value END) AS DPBSU342_F,
(CASE WHEN DT.ID=391 THEN DT.Value END) AS DPBSU351_F,
(CASE WHEN DT.ID=392 THEN DT.Value END) AS DPBSU352_F,
(CASE WHEN DT.ID=393 THEN DT.Value END) AS FlowBSU311_F,
(CASE WHEN DT.ID=394 THEN DT.Value END) AS FlowBSU312_F,
(CASE WHEN DT.ID=395 THEN DT.Value END) AS FlowBSU321_F,
(CASE WHEN DT.ID=396 THEN DT.Value END) AS FlowBSU322_F,
(CASE WHEN DT.ID=397 THEN DT.Value END) AS FlowBSU331_F,
(CASE WHEN DT.ID=398 THEN DT.Value END) AS FlowBSU332_F,
(CASE WHEN DT.ID=399 THEN DT.Value END) AS FlowBSU341_F,
(CASE WHEN DT.ID=400 THEN DT.Value END) AS FlowBSU342_F,
(CASE WHEN DT.ID=476 THEN DT.Value END) AS HART432_FAULT,
(CASE WHEN DT.ID=477 THEN DT.Value END) AS HART441_FAULT,
(CASE WHEN DT.ID=478 THEN DT.Value END) AS HART442_FAULT,
(CASE WHEN DT.ID=26 THEN DT.Value END) AS PBSU332,
(CASE WHEN DT.ID=27 THEN DT.Value END) AS PBSU341,
(CASE WHEN DT.ID=28 THEN DT.Value END) AS PBSU342,
(CASE WHEN DT.ID=29 THEN DT.Value END) AS PBSU351,
(CASE WHEN DT.ID=30 THEN DT.Value END) AS PBSU352,
(CASE WHEN DT.ID=31 THEN DT.Value END) AS TBSU311,
(CASE WHEN DT.ID=32 THEN DT.Value END) AS TBSU312,
(CASE WHEN DT.ID=33 THEN DT.Value END) AS TBSU321,
(CASE WHEN DT.ID=34 THEN DT.Value END) AS TBSU322,
(CASE WHEN DT.ID=35 THEN DT.Value END) AS TBSU331,
(CASE WHEN DT.ID=36 THEN DT.Value END) AS TBSU332,
(CASE WHEN DT.ID=37 THEN DT.Value END) AS TBSU341,
(CASE WHEN DT.ID=38 THEN DT.Value END) AS TBSU342,
(CASE WHEN DT.ID=39 THEN DT.Value END) AS TBSU351,
(CASE WHEN DT.ID=40 THEN DT.Value END) AS TBSU352,
(CASE WHEN DT.ID=41 THEN DT.Value END) AS DPBSU411,
(CASE WHEN DT.ID=42 THEN DT.Value END) AS DPBSU412,
(CASE WHEN DT.ID=43 THEN DT.Value END) AS DPBSU421,
(CASE WHEN DT.ID=44 THEN DT.Value END) AS DPBSU422,
(CASE WHEN DT.ID=45 THEN DT.Value END) AS DPBSU431,
(CASE WHEN DT.ID=46 THEN DT.Value END) AS DPBSU432,
(CASE WHEN DT.ID=47 THEN DT.Value END) AS DPBSU441,
(CASE WHEN DT.ID=48 THEN DT.Value END) AS DPBSU442,
(CASE WHEN DT.ID=49 THEN DT.Value END) AS FlowBSU411,
(CASE WHEN DT.ID=50 THEN DT.Value END) AS FlowBSU412,
(CASE WHEN DT.ID=52 THEN DT.Value END) AS FlowBSU422,
(CASE WHEN DT.ID=53 THEN DT.Value END) AS FlowBSU431,
(CASE WHEN DT.ID=54 THEN DT.Value END) AS FlowBSU432,
(CASE WHEN DT.ID=55 THEN DT.Value END) AS FlowBSU441,
(CASE WHEN DT.ID=56 THEN DT.Value END) AS FlowBSU442,
(CASE WHEN DT.ID=57 THEN DT.Value END) AS PBSU411,
(CASE WHEN DT.ID=58 THEN DT.Value END) AS PBSU412,
(CASE WHEN DT.ID=59 THEN DT.Value END) AS PBSU421,
(CASE WHEN DT.ID=60 THEN DT.Value END) AS PBSU422,
(CASE WHEN DT.ID=61 THEN DT.Value END) AS PBSU431,
(CASE WHEN DT.ID=62 THEN DT.Value END) AS PBSU432,
(CASE WHEN DT.ID=63 THEN DT.Value END) AS PBSU441,
(CASE WHEN DT.ID=64 THEN DT.Value END) AS PBSU442,
(CASE WHEN DT.ID=65 THEN DT.Value END) AS TBSU411,
(CASE WHEN DT.ID=66 THEN DT.Value END) AS TBSU412,
(CASE WHEN DT.ID=67 THEN DT.Value END) AS TBSU421,
(CASE WHEN DT.ID=68 THEN DT.Value END) AS TBSU422,
(CASE WHEN DT.ID=69 THEN DT.Value END) AS TBSU431,
(CASE WHEN DT.ID=70 THEN DT.Value END) AS TBSU432,
(CASE WHEN DT.ID=71 THEN DT.Value END) AS TBSU441,
(CASE WHEN DT.ID=72 THEN DT.Value END) AS TBSU442,
(CASE WHEN DT.ID=73 THEN DT.Value END) AS TimeAuditBSU311,
(CASE WHEN DT.ID=74 THEN DT.Value END) AS TimeAuditBSU312,
(CASE WHEN DT.ID=75 THEN DT.Value END) AS TimeAuditBSU321,
(CASE WHEN DT.ID=76 THEN DT.Value END) AS TimeAuditBSU322,
(CASE WHEN DT.ID=78 THEN DT.Value END) AS TimeAuditBSU332,
(CASE WHEN DT.ID=79 THEN DT.Value END) AS TimeAuditBSU341,
(CASE WHEN DT.ID=80 THEN DT.Value END) AS TimeAuditBSU342,
(CASE WHEN DT.ID=81 THEN DT.Value END) AS TimeAuditBSU351,
(CASE WHEN DT.ID=82 THEN DT.Value END) AS TimeAuditBSU352,
(CASE WHEN DT.ID=83 THEN DT.Value END) AS ParAuditBSU311,
(CASE WHEN DT.ID=84 THEN DT.Value END) AS ParAuditBSU312,
(CASE WHEN DT.ID=85 THEN DT.Value END) AS ParAuditBSU321,
(CASE WHEN DT.ID=86 THEN DT.Value END) AS ParAuditBSU322,
(CASE WHEN DT.ID=87 THEN DT.Value END) AS ParAuditBSU331,
(CASE WHEN DT.ID=88 THEN DT.Value END) AS ParAuditBSU332,
(CASE WHEN DT.ID=89 THEN DT.Value END) AS ParAuditBSU341,
(CASE WHEN DT.ID=90 THEN DT.Value END) AS ParAuditBSU342,
(CASE WHEN DT.ID=91 THEN DT.Value END) AS ParAuditBSU351,
(CASE WHEN DT.ID=92 THEN DT.Value END) AS ParAuditBSU352,
(CASE WHEN DT.ID=93 THEN DT.Value END) AS OldValBSU311,
(CASE WHEN DT.ID=94 THEN DT.Value END) AS OldValBSU312,
(CASE WHEN DT.ID=95 THEN DT.Value END) AS OldValBSU321,
(CASE WHEN DT.ID=96 THEN DT.Value END) AS OldValBSU322,
(CASE WHEN DT.ID=97 THEN DT.Value END) AS OldValBSU331,
(CASE WHEN DT.ID=98 THEN DT.Value END) AS OldValBSU332,
(CASE WHEN DT.ID=99 THEN DT.Value END) AS OldValBSU341,
(CASE WHEN DT.ID=100 THEN DT.Value END) AS OldValBSU342,
(CASE WHEN DT.ID=101 THEN DT.Value END) AS OldValBSU351,
(CASE WHEN DT.ID=102 THEN DT.Value END) AS OldValBSU352,
(CASE WHEN DT.ID=2 THEN DT.Value END) AS DPBSU312,
(CASE WHEN DT.ID=3 THEN DT.Value END) AS DPBSU321,
(CASE WHEN DT.ID=4 THEN DT.Value END) AS DPBSU322,
(CASE WHEN DT.ID=5 THEN DT.Value END) AS DPBSU331,
(CASE WHEN DT.ID=6 THEN DT.Value END) AS DPBSU332,
(CASE WHEN DT.ID=7 THEN DT.Value END) AS DPBSU341,
(CASE WHEN DT.ID=8 THEN DT.Value END) AS DPBSU342,
(CASE WHEN DT.ID=9 THEN DT.Value END) AS DPBSU351,
(CASE WHEN DT.ID=10 THEN DT.Value END) AS DPBSU352,
(CASE WHEN DT.ID=11 THEN DT.Value END) AS FlowBSU311,
(CASE WHEN DT.ID=12 THEN DT.Value END) AS FlowBSU312,
(CASE WHEN DT.ID=13 THEN DT.Value END) AS FlowBSU321,
(CASE WHEN DT.ID=14 THEN DT.Value END) AS FlowBSU322,
(CASE WHEN DT.ID=15 THEN DT.Value END) AS FlowBSU331,
(CASE WHEN DT.ID=16 THEN DT.Value END) AS FlowBSU332,
(CASE WHEN DT.ID=17 THEN DT.Value END) AS FlowBSU341,
(CASE WHEN DT.ID=18 THEN DT.Value END) AS FlowBSU342,
(CASE WHEN DT.ID=19 THEN DT.Value END) AS FlowBSU351,
(CASE WHEN DT.ID=20 THEN DT.Value END) AS FlowBSU352,
(CASE WHEN DT.ID=21 THEN DT.Value END) AS PBSU311,
(CASE WHEN DT.ID=22 THEN DT.Value END) AS PBSU312,
(CASE WHEN DT.ID=23 THEN DT.Value END) AS PBSU321,
(CASE WHEN DT.ID=24 THEN DT.Value END) AS PBSU322,
(CASE WHEN DT.ID=104 THEN DT.Value END) AS NewValBSU312,
(CASE WHEN DT.ID=105 THEN DT.Value END) AS NewValBSU321,
(CASE WHEN DT.ID=106 THEN DT.Value END) AS NewValBSU322,
(CASE WHEN DT.ID=107 THEN DT.Value END) AS NewValBSU331,
(CASE WHEN DT.ID=108 THEN DT.Value END) AS NewValBSU332,
(CASE WHEN DT.ID=109 THEN DT.Value END) AS NewValBSU341,
(CASE WHEN DT.ID=110 THEN DT.Value END) AS NewValBSU342,
(CASE WHEN DT.ID=111 THEN DT.Value END) AS NewValBSU351,
(CASE WHEN DT.ID=112 THEN DT.Value END) AS NewValBSU352,
(CASE WHEN DT.ID=113 THEN DT.Value END) AS TimeAuditBSU411,
(CASE WHEN DT.ID=114 THEN DT.Value END) AS TimeAuditBSU412,
(CASE WHEN DT.ID=115 THEN DT.Value END) AS TimeAuditBSU421,
(CASE WHEN DT.ID=116 THEN DT.Value END) AS TimeAuditBSU422,
(CASE WHEN DT.ID=117 THEN DT.Value END) AS TimeAuditBSU431,
(CASE WHEN DT.ID=118 THEN DT.Value END) AS TimeAuditBSU432,
(CASE WHEN DT.ID=119 THEN DT.Value END) AS TimeAuditBSU441,
(CASE WHEN DT.ID=120 THEN DT.Value END) AS TimeAuditBSU442,
(CASE WHEN DT.ID=121 THEN DT.Value END) AS ParAuditBSU411,
(CASE WHEN DT.ID=122 THEN DT.Value END) AS ParAuditBSU412,
(CASE WHEN DT.ID=123 THEN DT.Value END) AS ParAuditBSU421,
(CASE WHEN DT.ID=124 THEN DT.Value END) AS ParAuditBSU422,
(CASE WHEN DT.ID=125 THEN DT.Value END) AS ParAuditBSU431,
(CASE WHEN DT.ID=126 THEN DT.Value END) AS ParAuditBSU432,
(CASE WHEN DT.ID=127 THEN DT.Value END) AS ParAuditBSU441,
(CASE WHEN DT.ID=128 THEN DT.Value END) AS ParAuditBSU442,
(CASE WHEN DT.ID=130 THEN DT.Value END) AS OldValBSU412,
(CASE WHEN DT.ID=131 THEN DT.Value END) AS OldValBSU421,
(CASE WHEN DT.ID=132 THEN DT.Value END) AS OldValBSU422,
(CASE WHEN DT.ID=133 THEN DT.Value END) AS OldValBSU431,
(CASE WHEN DT.ID=134 THEN DT.Value END) AS OldValBSU432,
(CASE WHEN DT.ID=135 THEN DT.Value END) AS OldValBSU441,
(CASE WHEN DT.ID=136 THEN DT.Value END) AS OldValBSU442,
(CASE WHEN DT.ID=137 THEN DT.Value END) AS NewValBSU411,
(CASE WHEN DT.ID=138 THEN DT.Value END) AS NewValBSU412,
(CASE WHEN DT.ID=139 THEN DT.Value END) AS NewValBSU421,
(CASE WHEN DT.ID=140 THEN DT.Value END) AS NewValBSU422,
(CASE WHEN DT.ID=141 THEN DT.Value END) AS NewValBSU431,
(CASE WHEN DT.ID=142 THEN DT.Value END) AS NewValBSU432,
(CASE WHEN DT.ID=143 THEN DT.Value END) AS NewValBSU441,
(CASE WHEN DT.ID=144 THEN DT.Value END) AS NewValBSU442,
(CASE WHEN DT.ID=145 THEN DT.Value END) AS TimeAlarmBSU311,
(CASE WHEN DT.ID=146 THEN DT.Value END) AS TimeAlarmBSU312,
(CASE WHEN DT.ID=147 THEN DT.Value END) AS TimeAlarmBSU321,
(CASE WHEN DT.ID=148 THEN DT.Value END) AS TimeAlarmBSU322,
(CASE WHEN DT.ID=149 THEN DT.Value END) AS TimeAlarmBSU331,
(CASE WHEN DT.ID=150 THEN DT.Value END) AS TimeAlarmBSU332,
(CASE WHEN DT.ID=151 THEN DT.Value END) AS TimeAlarmBSU341,
(CASE WHEN DT.ID=152 THEN DT.Value END) AS TimeAlarmBSU342,
(CASE WHEN DT.ID=153 THEN DT.Value END) AS TimeAlarmBSU351,
(CASE WHEN DT.ID=154 THEN DT.Value END) AS TimeAlarmBSU352,
(CASE WHEN DT.ID=156 THEN DT.Value END) AS CodeAlarmBSU312,
(CASE WHEN DT.ID=157 THEN DT.Value END) AS CodeAlarmBSU321,
(CASE WHEN DT.ID=158 THEN DT.Value END) AS CodeAlarmBSU322,
(CASE WHEN DT.ID=159 THEN DT.Value END) AS CodeAlarmBSU331,
(CASE WHEN DT.ID=160 THEN DT.Value END) AS CodeAlarmBSU332,
(CASE WHEN DT.ID=161 THEN DT.Value END) AS CodeAlarmBSU341,
(CASE WHEN DT.ID=162 THEN DT.Value END) AS CodeAlarmBSU342,
(CASE WHEN DT.ID=163 THEN DT.Value END) AS CodeAlarmBSU351,
(CASE WHEN DT.ID=164 THEN DT.Value END) AS CodeAlarmBSU352,
(CASE WHEN DT.ID=165 THEN DT.Value END) AS PointAlarmBSU311,
(CASE WHEN DT.ID=166 THEN DT.Value END) AS PointAlarmBSU312,
(CASE WHEN DT.ID=167 THEN DT.Value END) AS PointAlarmBSU321,
(CASE WHEN DT.ID=168 THEN DT.Value END) AS PointAlarmBSU322,
(CASE WHEN DT.ID=169 THEN DT.Value END) AS PointAlarmBSU331,
(CASE WHEN DT.ID=170 THEN DT.Value END) AS PointAlarmBSU332,
(CASE WHEN DT.ID=171 THEN DT.Value END) AS PointAlarmBSU341,
(CASE WHEN DT.ID=172 THEN DT.Value END) AS PointAlarmBSU342,
(CASE WHEN DT.ID=173 THEN DT.Value END) AS PointAlarmBSU351,
(CASE WHEN DT.ID=174 THEN DT.Value END) AS PointAlarmBSU352,
(CASE WHEN DT.ID=175 THEN DT.Value END) AS DataAlarmBSU311,
(CASE WHEN DT.ID=176 THEN DT.Value END) AS DataAlarmBSU312,
(CASE WHEN DT.ID=177 THEN DT.Value END) AS DataAlarmBSU321,
(CASE WHEN DT.ID=178 THEN DT.Value END) AS DataAlarmBSU322,
(CASE WHEN DT.ID=179 THEN DT.Value END) AS DataAlarmBSU331,
(CASE WHEN DT.ID=180 THEN DT.Value END) AS DataAlarmBSU332,
(CASE WHEN DT.ID=182 THEN DT.Value END) AS DataAlarmBSU342,
(CASE WHEN DT.ID=183 THEN DT.Value END) AS DataAlarmBSU351,
(CASE WHEN DT.ID=184 THEN DT.Value END) AS DataAlarmBSU352,
(CASE WHEN DT.ID=185 THEN DT.Value END) AS CodeAlarmBSU411,
(CASE WHEN DT.ID=186 THEN DT.Value END) AS CodeAlarmBSU412,
(CASE WHEN DT.ID=187 THEN DT.Value END) AS CodeAlarmBSU421,
(CASE WHEN DT.ID=188 THEN DT.Value END) AS CodeAlarmBSU422,
(CASE WHEN DT.ID=189 THEN DT.Value END) AS CodeAlarmBSU423,
(CASE WHEN DT.ID=190 THEN DT.Value END) AS CodeAlarmBSU424,
(CASE WHEN DT.ID=191 THEN DT.Value END) AS CodeAlarmBSU441,
(CASE WHEN DT.ID=192 THEN DT.Value END) AS CodeAlarmBSU442,
(CASE WHEN DT.ID=193 THEN DT.Value END) AS PointAlarmBSU411,
(CASE WHEN DT.ID=194 THEN DT.Value END) AS PointAlarmBSU412,
(CASE WHEN DT.ID=195 THEN DT.Value END) AS PointAlarmBSU421,
(CASE WHEN DT.ID=196 THEN DT.Value END) AS PointAlarmBSU422,
(CASE WHEN DT.ID=197 THEN DT.Value END) AS PointAlarmBSU431,
(CASE WHEN DT.ID=198 THEN DT.Value END) AS PointAlarmBSU432,
(CASE WHEN DT.ID=199 THEN DT.Value END) AS PointAlarmBSU441,
(CASE WHEN DT.ID=200 THEN DT.Value END) AS PointAlarmBSU442,
(CASE WHEN DT.ID=201 THEN DT.Value END) AS DataAlarmBSU411,
(CASE WHEN DT.ID=202 THEN DT.Value END) AS DataAlarmBSU412,
(CASE WHEN DT.ID=203 THEN DT.Value END) AS DataAlarmBSU421,
(CASE WHEN DT.ID=204 THEN DT.Value END) AS DataAlarmBSU422,
(CASE WHEN DT.ID=205 THEN DT.Value END) AS DataAlarmBSU431,
(CASE WHEN DT.ID=206 THEN DT.Value END) AS DataAlarmBSU432,
(CASE WHEN DT.ID=208 THEN DT.Value END) AS DataAlarmBSU442,
(CASE WHEN DT.ID=209 THEN DT.Value END) AS AnalizComp1An_DT1,
(CASE WHEN DT.ID=210 THEN DT.Value END) AS AnalizComp1CH4_mol,
(CASE WHEN DT.ID=211 THEN DT.Value END) AS AnalizComp1C2H6_mol,
(CASE WHEN DT.ID=212 THEN DT.Value END) AS AnalizComp1C3H8_mol,
(CASE WHEN DT.ID=213 THEN DT.Value END) AS AnalizComp1iC4H10_mol,
(CASE WHEN DT.ID=214 THEN DT.Value END) AS AnalizComp1nC4H10_mol,
(CASE WHEN DT.ID=215 THEN DT.Value END) AS AnalizComp1neoC5H12_mol,
(CASE WHEN DT.ID=216 THEN DT.Value END) AS AnalizComp1iC5H12_mol,
(CASE WHEN DT.ID=217 THEN DT.Value END) AS AnalizComp1nC5H12_mol,
(CASE WHEN DT.ID=218 THEN DT.Value END) AS AnalizComp1C6plus_mol,
(CASE WHEN DT.ID=219 THEN DT.Value END) AS AnalizComp1N2_mol,
(CASE WHEN DT.ID=220 THEN DT.Value END) AS AnalizComp1O2_mol,
(CASE WHEN DT.ID=221 THEN DT.Value END) AS AnalizComp1CO2_mol,
(CASE WHEN DT.ID=222 THEN DT.Value END) AS AnalizComp1He_mol,
(CASE WHEN DT.ID=223 THEN DT.Value END) AS AnalizComp1H_mol,
(CASE WHEN DT.ID=224 THEN DT.Value END) AS AnalizComp1H2O_mol,
(CASE WHEN DT.ID=225 THEN DT.Value END) AS AnalizComp1CH4_vol,
(CASE WHEN DT.ID=226 THEN DT.Value END) AS AnalizComp1C2H6_vol,
(CASE WHEN DT.ID=227 THEN DT.Value END) AS AnalizComp1C3H8_vol,
(CASE WHEN DT.ID=228 THEN DT.Value END) AS AnalizComp1iC4H10_vol,
(CASE WHEN DT.ID=229 THEN DT.Value END) AS AnalizComp1nC4H10_vol,
(CASE WHEN DT.ID=230 THEN DT.Value END) AS AnalizComp1neoC5H12_vol,
(CASE WHEN DT.ID=231 THEN DT.Value END) AS AnalizComp1iC5H12_vol,
(CASE WHEN DT.ID=232 THEN DT.Value END) AS AnalizComp1nC5H12_vol,
(CASE WHEN DT.ID=234 THEN DT.Value END) AS AnalizComp1N2_vol,
(CASE WHEN DT.ID=235 THEN DT.Value END) AS AnalizComp1O2_vol,
(CASE WHEN DT.ID=236 THEN DT.Value END) AS AnalizComp1CO2_vol,
(CASE WHEN DT.ID=237 THEN DT.Value END) AS AnalizComp1He_vol,
(CASE WHEN DT.ID=238 THEN DT.Value END) AS AnalizComp1H_vol,
(CASE WHEN DT.ID=239 THEN DT.Value END) AS AnalizComp1H2O_vol,
(CASE WHEN DT.ID=240 THEN DT.Value END) AS AnalizComp1Koeff,
(CASE WHEN DT.ID=241 THEN DT.Value END) AS AnalizComp1Mol_Mass,
(CASE WHEN DT.ID=242 THEN DT.Value END) AS AnalizComp1UTS_Lo,
(CASE WHEN DT.ID=243 THEN DT.Value END) AS AnalizComp1UTS_Hi,
(CASE WHEN DT.ID=244 THEN DT.Value END) AS AnalizComp1Abs_ro,
(CASE WHEN DT.ID=245 THEN DT.Value END) AS AnalizComp1Rel_ro,
(CASE WHEN DT.ID=246 THEN DT.Value END) AS AnalizComp1Vobbe_Lo,
(CASE WHEN DT.ID=247 THEN DT.Value END) AS AnalizComp1Vobbe_Hi,
(CASE WHEN DT.ID=248 THEN DT.Value END) AS AnalizComp1An_Num,
(CASE WHEN DT.ID=249 THEN DT.Value END) AS AnalizComp1Status,
(CASE WHEN DT.ID=250 THEN DT.Value END) AS AnalizComp2An_DT1,
(CASE WHEN DT.ID=251 THEN DT.Value END) AS AnalizComp2CH4_mol,
(CASE WHEN DT.ID=252 THEN DT.Value END) AS AnalizComp2C2H6_mol,
(CASE WHEN DT.ID=253 THEN DT.Value END) AS AnalizComp2C3H8_mol,
(CASE WHEN DT.ID=254 THEN DT.Value END) AS AnalizComp2iC4H10_mol,
(CASE WHEN DT.ID=255 THEN DT.Value END) AS AnalizComp2nC4H10_mol,
(CASE WHEN DT.ID=256 THEN DT.Value END) AS AnalizComp2neoC5H12_mol,
(CASE WHEN DT.ID=257 THEN DT.Value END) AS AnalizComp2iC5H12_mol,
(CASE WHEN DT.ID=258 THEN DT.Value END) AS AnalizComp2nC5H12_mol,
(CASE WHEN DT.ID=260 THEN DT.Value END) AS AnalizComp2N2_mol,
(CASE WHEN DT.ID=261 THEN DT.Value END) AS AnalizComp2O2_mol,
(CASE WHEN DT.ID=262 THEN DT.Value END) AS AnalizComp2CO2_mol,
(CASE WHEN DT.ID=263 THEN DT.Value END) AS AnalizComp2He_mol,
(CASE WHEN DT.ID=264 THEN DT.Value END) AS AnalizComp2H_mol,
(CASE WHEN DT.ID=265 THEN DT.Value END) AS AnalizComp2H2O_mol,
(CASE WHEN DT.ID=266 THEN DT.Value END) AS AnalizComp2CH4_vol,
(CASE WHEN DT.ID=267 THEN DT.Value END) AS AnalizComp2C2H6_vol,
(CASE WHEN DT.ID=268 THEN DT.Value END) AS AnalizComp2C3H8_vol,
(CASE WHEN DT.ID=269 THEN DT.Value END) AS AnalizComp2iC4H10_vol,
(CASE WHEN DT.ID=270 THEN DT.Value END) AS AnalizComp2nC4H10_vol,
(CASE WHEN DT.ID=271 THEN DT.Value END) AS AnalizComp2neoC5H12_vol,
(CASE WHEN DT.ID=272 THEN DT.Value END) AS AnalizComp2iC5H12_vol,
(CASE WHEN DT.ID=273 THEN DT.Value END) AS AnalizComp2nC5H12_vol,
(CASE WHEN DT.ID=274 THEN DT.Value END) AS AnalizComp2C6plus_vol,
(CASE WHEN DT.ID=275 THEN DT.Value END) AS AnalizComp2N2_vol,
(CASE WHEN DT.ID=276 THEN DT.Value END) AS AnalizComp2O2_vol,
(CASE WHEN DT.ID=277 THEN DT.Value END) AS AnalizComp2CO2_vol,
(CASE WHEN DT.ID=278 THEN DT.Value END) AS AnalizComp2He_vol,
(CASE WHEN DT.ID=279 THEN DT.Value END) AS AnalizComp2H_vol,
(CASE WHEN DT.ID=280 THEN DT.Value END) AS AnalizComp2H2O_vol,
(CASE WHEN DT.ID=281 THEN DT.Value END) AS AnalizComp2Koeff,
(CASE WHEN DT.ID=282 THEN DT.Value END) AS AnalizComp2Mol_Mass,
(CASE WHEN DT.ID=283 THEN DT.Value END) AS AnalizComp2UTS_Lo,
(CASE WHEN DT.ID=284 THEN DT.Value END) AS AnalizComp2UTS_Hi
FROM
(SELECT [Date],[ID],[Value] FROM [ArchiveAnalog]) AS DT
Yes ... that should be funny , but it works very slow.
Is it real to optimize this .... ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 PIVOT 关系运算符,
但为了获得最佳性能,您可以创建一个物化视图或创建一个帮助表,其中数据将按行复制。
You can use the PIVOT relational operators
But for full performance you may create a materialized view or create a help table where the data would be copied in rows.
当你有这么多 CASE 语句时应该会很慢...
是否有理由需要构建一个包含这么多列的表行集?您可能正在错误地接近它......
Should be slow when you have so many CASE statements...
Is there a reason why you need to build a table rowset with so many columns? You are probably approaching it wrong...