oracle分組取每組第一條資料,oracle每組

來源:互聯網
上載者:User

oracle分組取每組第一條資料,oracle每組
oracle分組後取每組第一條資料 ‘資料格式  分組取第一條的效果  

[sql]SELECT *           FROM (SELECT ROW_NUMBER() OVER(PARTITION BY x ORDER BY y DESC) rn,                 test1.*                 FROM test1)          WHERE rn = 1  ;



oracle開展分組後,取出每組的前幾條資料

oracle進行分組後,取出每組的前幾條資料SELECT *FROM (SELECT 分組的欄位名,ROW_NUMBER() OVER(PARTITION BY 分組的欄位名 ORDER BY 排序的欄位名) AS RNFROM 表名)WHERE RN <= 10??
 
sql 分組取每組的前幾條資料 怎做

select * from 表名 a where exists (select top 2 * from
(select a,a1,a2 from 表名 group by a,a2) b where a.a=b.a and a.a2=b.a2)
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.