select * into tmp_lzw1 From tb_sc_user_cz200905 a where exists (select * From dhhm b where b.col001=a.servnumber)
select servnumber,max(chgamt) as chamt,recdate into tmp_lzw2 from tmp_lzw1 where chgamt>=50 group by servnumber,recdate
select identity(int, 1, 1) rn,a.* into tmp_lzw3 from tmp_lzw2 a order by servnumber,chamt desc
select * into tmp_lzw4 from tmp_lzw3 a where a.rn = (select min(rn) from tmp_lzw3 b where a.servnumber = b.servnumber)
create table tmp_lzw_stopkey_us30(dhhm varchar2(11),stopkey varchar2(10));
create table tmp_lzw_stopkey_us30new nologging as
select * from (select dhhm,stopkey,row_number()over(partition by stopkey order by dhhm desc )rn
from tmp_lzw_stopkey_us30)
where rn=1;
select * From tmp_lzw_stopkey_us30new