hoho_12 2016-06-02 08:16 采纳率: 89.3%
浏览 1128

oracle 行列式转换 系统自带的hr用户进行查询

HR用户下进行以下查询:

跨越COUNTRIES和REGIONS数据表,按照区域名(REGION_NAME)
统计各区域设立机构国家的数量。要求输出结果如下:

REGION Asia Americas Europe Others

COUNTIES_NUM 6 5 8 6

  • 写回答

1条回答 默认 最新

  • cbaxt 2016-06-02 08:46
    关注

    使用decode

    select Asia,Americas,Europe,(count-Asia-Americas-Europe) Others from (
    select
    sum(decode(REGION_NAME,'Asia',1,0)) Asia,
    sum(decode(REGION_NAME,'Americas',1,0)) Americas,
    sum(decode(REGION_NAME,'Europe ',1,0)) Europe,
    count(1) count
    from (select 'REGION_NAME'REGION_NAME from dual)

    )

    评论

报告相同问题?