W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
SELECT * FROM(
SELECT V.VENDOR_CODE,
V.VENDOR_NAME,
V.VENDOR_TYPE,
V.SMTP_ADDR,
V.MOB_NUMBER,
U.USER_NAME,
ROW_NUMBER() OVER(ORDER BY V.VENDOR_CODE) AS RN
FROM T_BD_VENDOR V,
T_BASE_USER U,
'(SELECT S.*
FROM (
SELECT T.*, ROW_NUMBER() OVER (PARTITION BY T.VENDOR_CODE ORDER BY T.USER_CODE) AS GROUP_IDX
FROM T_BD_USER_VENDOR_REL T
)S
WHERE S.GROUP_IDX = 1
)R'
WHERE 1=1
AND V.VENDOR_CODE = R.VENDOR_CODE(+)
AND R.USER_CODE = U.USER_CODE(+)
)
WHERE RN BETWEEN 1 AND 20
其中綠色部分表示從中間關(guān)聯(lián)表中根據(jù)VENDOR_CODE字段重復(fù)的只取出一條。 如上圖只取出根據(jù)VENDOR_CODE分組,根據(jù)USER_CODE排序的第一條數(shù)據(jù)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: