日期:2014-05-17  浏览次数:20785 次

一个查询语句,需要过滤掉对应多个字段的重复记录。求指教
需要过滤重复的字段 dcfb2.BATCH,dcfb2.SRC,dcfb1.LOGIN_ID
原始的SQL语句:
SQL code

SELECT * FROM 
  (SELECT A.* ,ROWNUM RN FROM 
    (SELECT REMAND_ID,PROCESS_ID,LOGIN_ID,su.USER_NAME as CREATE_USER_NAME,TO_CHAR(GMT_CREATE,'YYYY-MM-DD') 
      AS GMT_CREATE,TO_CHAR(GMT_MODIFY,'YYYY-MM-DD') 
        AS GMT_MODIFY,MODULE_NAME,OWNER,
      DEMAND_NO,SPEC_REQURE,DESIGN_IDEAS,IS_ONLINE,AUTHOR,AFFECT_FUNC,TEST_FUNC,TEST_METHOD,
      DECODE (TYPE, 0, '前台', 1, 'IDL', 2, '后台', 3, '配置的脚本', 4, '表名或其他数据库对象名', 5, '存储过程', 6, 'PDM或其他对象脚本') 
      as TYPE,
      NAME,SRC,FUNC,DESCRIPT,BIZ_TYPE,APP_TYPE,dcfh.BUG_ID,dcfh.batch as BATCH,dcfb2.ID as BIZ_ID,dcfb2.TEST_RESULT as TEST_RESULT
      FROM DEV_CODE_FILE_BATCH dcfb1,DEV_CODE_FILE_HEAD  dcfh,DEV_CODE_FILE_BIZ   dcfb2,SHCM_USER su
      WHERE dcfb1.ID = dcfh.BATCH and dcfb1.ID = dcfb2.BATCH and dcfb1.LOGIN_ID=su.LOGINID
      AND remand_id = '信息-2011-34384'
     
      ORDER BY  BATCH,TYPE
      ) A
      WHERE ROWNUM <=99999999
      ) WHERE RN > 0;


求解!!!

------解决方案--------------------
group by 后只能用max(),min()