标签:row_number over 第一条 oracle
看看以前的私密日志,原来自己之前被很多小而简单的问题困惑过!
看着那时候我们还是新手中的新手做的备忘笔记!
其实就是用了Oracle的统计函数而已!
以前的日记(看样子应该是以前公司的源码,呵呵……)如下:勿喷!
对多数据进行分组排序后取每组第一条记录:
SELECT * FROM ( SELECT ROW_NUMBER() OVER( PARTITION BY ZA40011_3.URIAGE_DENPYO_NO,ZA40011_3.URIAGE_DENPYO_ROW_NO ORDER BY ZA40011_3.KAKUTEI_SURYO_CS, ZA40011_3.KAKUTEI_SURYO_BL, ZA40011_3.KAKUTEI_SURYO_BT, ZA40011_3.SYUKKA_SHIJI_NO, ZA40011_3.SYUKKA_SHIJI_ROW_NO DESC) LEV, ZA40011_3 .* FROM WT_001_ZA40011_22070_2 ZA40011_2, WT_001_ZA40011_22070_3 ZA40011_3, JT_GYOMU_URIAGE_DETAIL URIAGE_DETAIL WHERE ZA40011_2.KAISYA_CODE = URIAGE_DETAIL.KAISYA_CODE AND ZA40011_2.URIAGE_DENPYO_NO = URIAGE_DETAIL.URIAGE_DENPYO_NO AND ZA40011_2.URIAGE_DENPYO_ROW_NO = URIAGE_DETAIL.ROW_NO AND URIAGE_DETAIL.KAISYA_CODE = ZA40011_3.KAISYA_CODE AND URIAGE_DETAIL.URIAGE_DENPYO_NO = ZA40011_3.URIAGE_DENPYO_NO AND URIAGE_DETAIL.ROW_NO = ZA40011_3.URIAGE_DENPYO_ROW_NO AND ZA40011_3.KEPPIN_RIYU_CODE IS NOT NULL ) WHERE LEV = 1 -- ORDER BY KAKUTEI_SURYO_CS DESC
标签:row_number over 第一条 oracle
原文地址:http://blog.csdn.net/fullstack/article/details/38439933