日期:2014-05-17 浏览次数:20714 次
select t2.esc_Orderid, t1.payment_id from payment t1 left join ctoc_order t2 on t2.order_id = t1.service_order where t1.payment_id in( '820120528094530833273', '820120528122552834900') --根据支付ID,显示订单ID和支付ID.这样查询会关联2个表,有没有速度快一点的方式. 顺便求一个好用点的sql性能分析器.
with aa as ( select t1.payment_id,t1.service_order from t1 where t1.payment_id in ('820120528094530833273','820120528122552834900') ) select t2.esc_orderid,aa.payment_id from aa left join t2 on t2.order_id = t1.service_order
------解决方案--------------------
create table s41071030 ( sno int , sname varchar2(10), ssex char(1), sage int, sdept varchar2(10) ); / create table c41071030( cno int, cname varchar2(10), cpno int, ccredit varchar2(10) ); / create table sc41071030 ( sno int, cno int, grade int ); / insert into sc41071030 select 1001,1,40 from dual union all select 1001,2,45 from dual union all select 1001,3,50 from dual union all select 1002,1,44 from dual union all select 1002,2,40 from dual union all --select 1002,3,50 from dual union all select 1003,1,60 from dual; / insert into s41071030(sno,sdept) select 1001,'CS' from dual union all select 1002,'CS' from dual union all select 1003,'CS' from dual union all select 1004,'dd' from dual; / with cte as ( select a.sno ,count(1) as v_count from sc41071030 a inner join s41071030 b on a.sno=b.sno where b.sdept='CS' group by a.sno order by count(1) desc ) select a.* from cte a inner join ( select max(v_count) as v_count from cte )b on a.v_count=b.v_count /*drop table s41071030; drop table c41071030; drop table sc41071030;*/