SQL> select owner , view_name , text from dba_views where view_name='V_WARM_ASSET';
OWNER VIEW_NAME TEXT
---------- ---------- --------------------------------------------------
ALCM V_WARM_ASS select '500kV' as 类别,
ET sum(case
when status = '运行中' then
1
else
0
end) as 正常,
sum(case
when status = '停止使用' then
1
else
0
end) as 异常,
sum(case
when status = '删除' then
1
else
0
end) as 停运
from sc_asset t
where t.ydtf_dydj = 1
union all
select '220kV' as 类别,
sum(case
when status = '运行中' then
else
1
0
end) as 正常,
sum(case
when status = '停止使用' then
1
else
0
end) as 异常,
sum(case
when status = '删除' then
1
else
0
end) as 停运
from sc_asset t
where t.ydtf_dydj = 2
union all
select '110kV' as 类别,
sum(case
when status = '运行中' then
1
else
0
end) as 正常,
sum(case
when status = '停止使用' then
1
else
0
end) as 异常,
sum(case
when status = '删除' then
1
else
0
end) as 停运
from sc_asset t
where t.ydtf_dydj = 3
union all
select '其它等级' as 类别,
sum(case
when status = '运行中' then
1
else
0
end) as 正常,
sum(case
when status = '停止使用' then
1
else
0
end) as 异常,
sum(case
when status = '删除' then
1
else
0
end) as 停运
from sc_asset t
where t.ydtf_dydj not in (1, 2, 3)
union all
/*设备类型*/
。。。
就是这么一个语句,有十多个union all,运行直接把服务器拖死,大家看看要怎么优化呢?
附件里面是完整的语句
2014-10-15 14:27 上传
点击文件名下载附件
16.32 KB, 下载次数: 40