select top 10 * from v_pub_school where s_area='南京' select * into cdr_school_list from cdr00057 where ((tc_calling in (select phone_number from temp_nj_school)) or (tc_calling in (select phone_number from temp_nj_school))) select phone_number from temp_nj_school select name from sysobjects where name like '%city%'; select count(1),s_unit from temp_nj_school group by s_unit order by 1 desc select distinct phone_number,s_unit into temp_school_topten from temp_nj_school where s_unit in ('南京信息工程大学','金陵科技学院' ,'三江学院','南京林业大学' ,'东南大学','南京审计学院' ,'南京航空航天大学','南京理工大学' ,'中国药科大学' ,'河海大学' ) select ans_time,end_time,calling,called into cdr_school_list from pcc00022 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))) insert into cdr_school_list select ans_time,end_time,calling,called from pcc00021 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); insert into cdr_school_list select ans_time,end_time,calling,called from pcc00020 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); insert into cdr_school_list select ans_time,end_time,calling,called from pcc00019 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); insert into cdr_school_list select ans_time,end_time,calling,called from pcc00018 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); insert into cdr_school_list select ans_time,end_time,calling,called from pcc00017 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); insert into cdr_school_list select ans_time,end_time,calling,called from pcc00016 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten))); select min(ans_time) from cdr_school_list select calling,A.s_unit as calling_sch,called,B.s_unit as called_sch ,datediff(second,ans_time,end_time) as call_length into cdr_school_list1 from (select * from cdr_school_list l left join temp_school_topten r on l.calling=r.phone_number ) A left join temp_school_topten B on a.called = B.phone_number select count(*) from pcc00022 where (calling_city_id =1 or called_city_id=1) and ((calling in (select phone_number from temp_school_topten)) or (called in (select phone_number from temp_school_topten)))