SELECT occud04,occ14 FROM (SELECT occud04,occ14,ROWNUM AS a1 FROM ds1.my_occ_file_view WHERE occud04 IS NOT NULL AND occ14 > 0 AND occud54 = '1' AND occud04 IN (SELECT m_no FROM tab_2020_0822)) b WHERE b.a1 IN (SELECT MAX(NUM) FROM (SELECT ROWNUM NUM ,occud04 FROM ds1.my_occ_file_view WHERE occud04 IS NOT NULL AND occ14 > 0 AND occud54 = '1' AND occud04 IN (SELECT m_no FROM tab_2020_0822)) a GROUP BY a.occud04)
思路:rownum,然后取最大的,或者最小的,然后用in 条件筛选