zoukankan      html  css  js  c++  java
  • oracle中列转行写法

    --查询为列的原始代码
    SELECT
    1 AS num, t.id, t.company_shorthand AS CountryCode FROM qhyscm.tab_base_company t WHERE t.company_type = '1' AND t.company_shorthand = 'EORLK' UNION ALL SELECT 2 AS num, t.id, t.company_shorthand AS CountryCode FROM qhyscm.tab_base_company t WHERE t.company_type = '2' AND t.company_shorthand = 'IORLK' UNION ALL SELECT 3 AS num, t.id, t.company_shorthand AS CountryCode FROM qhyscm.tab_base_company t WHERE t.company_type = '3' AND t.company_shorthand = 'SORLK' UNION ALL SELECT 4 AS num, t.id, t.company_shorthand AS CountryCode FROM qhyscm.tab_base_company t WHERE t.company_type = '4' AND t.company_shorthand = 'LK'

     列转行写法

    SELECT
        *
    FROM
        (
        SELECT
            1 AS num, t.id
        FROM
            qhyscm.tab_base_company t
        WHERE
            t.company_type = '1'
            AND t.company_shorthand = 'EORLK'
    UNION ALL
        SELECT
            2 AS num, t.id
        FROM
            qhyscm.tab_base_company t
        WHERE
            t.company_type = '2'
            AND t.company_shorthand = 'IORLK'
    UNION ALL
        SELECT
            3 AS num, t.id
        FROM
            qhyscm.tab_base_company t
        WHERE
            t.company_type = '3'
            AND t.company_shorthand = 'SORLK'
    UNION ALL
        SELECT
            4 AS num, t.id
        FROM
            qhyscm.tab_base_company t
        WHERE
            t.company_type = '4'
            AND t.company_shorthand = 'LK') pivot( max(id) FOR num IN ( 1 AS eor, 2 AS ior, 3 AS sor, 4 AS wl ) )
    ORDER BY
        1

  • 相关阅读:
    关于《注意力模型--Attention注意力机制》的学习
    神经网络参数计算
    FPN(feature pyramid networks)算法讲解
    RetinaNet-focal loss
    论文阅读: RetinaNet
    CNN+LSTM:看图说话
    非极大值抑制-NMS
    python IO文件操作 file文件操作
    软件测试定义 分类
    软件生命周期
  • 原文地址:https://www.cnblogs.com/wangquanyi/p/13999964.html
Copyright © 2011-2022 走看看