select * from( select rate_id,title,TO_CHAR(RATE_PUBL_DATE, 'YYYY-MM-DD HH:MM') RES_DATE from( select * from(select sec_uni_code, RATE_PUBL_DATE, RATE_ID,'【主体评级】 ' || ISS_RATE_TITLE_NEW title,row_number() over(partition by sec_uni_code,rate_publ_date order by 1) r from wxdata.wx_sec_comm where sec_uni_code = 103037402) where r=1)order by RES_DATE desc)
sql去重(根据两个字段去重)
今天搞这个,差点被搞残废了,幸亏DB组的哥们帮忙,这里mark下:
select * from( select rate_id,title,TO_CHAR(RATE_PUBL_DATE, 'YYYY-MM-DD HH:MM') RES_DATE from( select * from(select sec_uni_code, RATE_PUBL_DATE, RATE_ID,'【主体评级】 ' || ISS_RATE_TITLE_NEW title,row_number() over(partition by sec_uni_code,rate_publ_date order by 1) r from wxdata.wx_sec_comm where sec_uni_code = 103037402) where r=1)order by RES_DATE desc)
select * from( select rate_id,title,TO_CHAR(RATE_PUBL_DATE, 'YYYY-MM-DD HH:MM') RES_DATE from( select * from(select sec_uni_code, RATE_PUBL_DATE, RATE_ID,'【主体评级】 ' || ISS_RATE_TITLE_NEW title,row_number() over(partition by sec_uni_code,rate_publ_date order by 1) r from wxdata.wx_sec_comm where sec_uni_code = 103037402) where r=1)order by RES_DATE desc)