sql union 与多个order by 一起使用

经过好长的一段时间,才把union与多个 order by一起联合使用。先看代码:

 

 

   select * from

       (select top 1000  id, businessNum,rebateNum,specialNum 
        from counter 
        
where  type = 1 
      order by businessNum,billNum) 
as t
         union all
        select 
* from
        (select top 
1000 id, businessNum,rebateNum,specialNum
        from counter 
        
where   type = 2
       order by businessNum,billNum)
as tg 

 

 这里需要注意的问题 在内查询中,要用top 进行限定。

 

 

posted on 2011-05-13 03:48  wtq  阅读(3771)  评论(0编辑  收藏  举报