HR用户下进行以下查询:
跨越COUNTRIES和REGIONS数据表,按照区域名(REGION_NAME)
统计各区域设立机构国家的数量。要求输出结果如下:
COUNTIES_NUM 6 5 8 6
使用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)
)