select q.*
from (select d.kpi_node_code as inde, d.*
from kpi_data d
where d.kpi_key = 'TOP_SPZLJK'
and d.kpi_node_code in (select rssc_code from tm_rssc)
union
select bo.rssc_code as inde, kd.*
from kpi_data kd, tm_business_office bo
where kd.kpi_node_code = bo.bo_code
and kd.kpi_key = 'TOP_SPZLJK'
union
select i.bm_id || rownum as inde ,kd.* from kpi_data kd, tm_dealer_net_info i
where kd.kpi_node_code=i.bm_id and kd.kpi_key='TOP_SPZLJK'
) q
where q.KPI_PERIOD = 'Y2012-01'
order by inde;union不是会去掉重复向吗?在这tm_dealer_net_info表中一个bm_id有多个dealer_code ??
谢谢各位高手赐教啊!!!!!!!
from (select d.kpi_node_code as inde, d.*
from kpi_data d
where d.kpi_key = 'TOP_SPZLJK'
and d.kpi_node_code in (select rssc_code from tm_rssc)
union
select bo.rssc_code as inde, kd.*
from kpi_data kd, tm_business_office bo
where kd.kpi_node_code = bo.bo_code
and kd.kpi_key = 'TOP_SPZLJK'
union
select i.bm_id || rownum as inde ,kd.* from kpi_data kd, tm_dealer_net_info i
where kd.kpi_node_code=i.bm_id and kd.kpi_key='TOP_SPZLJK'
) q
where q.KPI_PERIOD = 'Y2012-01'
order by inde;union不是会去掉重复向吗?在这tm_dealer_net_info表中一个bm_id有多个dealer_code ??
谢谢各位高手赐教啊!!!!!!!
from (select d.kpi_node_code as inde, d.*
from kpi_data d
where d.kpi_key = 'TOP_SPZLJK'
and d.kpi_node_code in (select rssc_code from tm_rssc)
union
select bo.rssc_code as inde, kd.*
from kpi_data kd, tm_business_office bo
where kd.kpi_node_code = bo.bo_code
and kd.kpi_key = 'TOP_SPZLJK'
union
select i.bm_id || rownum as inde ,kd.* from kpi_data kd, tm_dealer_net_info i
where kd.kpi_node_code=i.bm_id and kd.kpi_key='TOP_SPZLJK'
) q
where q.KPI_PERIOD = 'Y2012-01'
order by inde;
select * from (
select * from t1
MultiSet Union
select * from t2
Multiset Union
select * from t3
) t
另外对于同一条sql,distinct 、group by可以去重。
distinct 、group by 开销太大了。。
AND ROWID NOT IN(SELECT MIN(字段名) FROM tablename GROUP BY 字段名HAVING COUNT(*) > 1