1,su - db2inst
2,db2 connect to ids
3,db2stop force
4,db2 list db directory
5,db2 list tables for all
6,db2 describe table tablename
7,db2 "restore db JVC from ."
8,select * from (select a.* , rownumber() over(order by rate desc) as rn from ( select w201406.*,w2014_06.* ,case when phonesum is null then 0 else phonesum*1.00/sum end as rate from ( select count(distinct SESSION_ID) as sum ,service_code from IDS.TRACE_2014_6 where 1=1 and LOGIN_AT >= ‘2014-06-17 00:00:00‘ and LOGIN_AT <= ‘2014-06-17 23:59:59‘ group by service_code ) w201406 left join ( select count(distinct SESSION_ID) as phonesum ,service_code from IDS.TRACE_VID_2014_6 where 1=1 and id_type = 9191 and LOGIN_AT >= ‘2014-06-17 00:00:00‘ and LOGIN_AT <= ‘2014-06-17 23:59:59‘ group by service_code ) w2014_06 on w201406.service_code = w2014_06.service_code ) a order by rate desc ) z where rn between 1 and 100 with ur"
原文:http://www.cnblogs.com/awk1983/p/3795051.html