sql去掉多条重复只显示一条

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 条件筛选

posted on 2020-08-22 18:19  chenzhe1  阅读(525)  评论(0编辑  收藏  举报

导航