简体   繁体   English

子查询中Order By对外部查询排序的影响

[英]Effect of Order By in sub-query on outer query sorting

I have a query with sub-query getting data from other tables. 我有一个带有子查询的查询,该查询从其他表中获取数据。 Does the order by clause in sub-query also sorts the records of the outer query in the same order?? 子查询中的order by子句是否也以相同顺序对外部查询的记录进行排序?

Query is of the form: 查询的形式为:

select p.email email, max(p.firstname) firstname,max(p.lastname) lastname  
from abc p, xyz c 
where p.companyid=c.companyid 
and  c.company!=''  
and locationid in (  
                   select locationid  
                   from mno tr   
                   where 1=1 
                   AND tr.inc in (7,8,9)  
                   AND tr.topic in( 'Callidus Cloud')  
                   AND tr.inc IS NOT NULL  
                   order by inc desc 
                  ) 
AND c.crange IN ('100-249','250-499','500-999','1000-4999'
                  ,'5000-9999','50000-100000','>100000') 
group by p.email limit 7 offset 0

What happens in sub query remains in sub query. 子查询中发生的情况保留在子查询中。 It only returns the value you asked for. 它仅返回您要求的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM