码迷,mamicode.com
首页 > 其他好文 > 详细

查询 去重后的多列数据

时间:2015-07-07 18:48:49      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

select * from (
                    select row_number() over(order by  OrderId) as rownum ,OrderId,UserEmail from TOrder
                    where UserEmail IS NOT NULL AND UserEmail <> ‘‘
               )kk
where kk.rownum in 
                      (
                            select  max(rownum) num from 
                            (
                            select row_number() over(order by  OrderId) as rownum ,OrderId,UserEmail from TOrder
                            where UserEmail IS NOT NULL AND UserEmail <> ‘‘
                            )t
                            group by t.UserEmail 
                        ) 

 

查询 去重后的多列数据

标签:

原文地址:http://www.cnblogs.com/porray/p/4627725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!