select * from (select * from (select max(datadate) as datadate1,org_code as org_code1,index_code as index_code1 from "APP_DM_SCHEMA".lsds_apply where index_code in ('02040200045','12040200059','1204020060','12040200025') and org_code='F3202' and datadate<='2021-05-25' GROUP BY substring(datadate,1,4),org_code,index_code ORDER BY substring(datadate,1,4) desc) t,"APP_DM_SCHEMA".lsds_apply y where
t.datadate1=y.datadate and t.org_code1=y.org_code and t.index_code1=y.index_code)tmp ORDER BY tmp.datadate desc`在这里插入
select y.* from "APP_DM_SCHEMA".lsds_apply y,(select max(datadate) as datadate1,org_code as org_code1,index_code as index_code1 from "APP_DM_SCHEMA".lsds_apply where index_code in ('02040200045','12040200059','1204020060','12040200025') and org_code in ('F3202','F3204','F3215','F3217','F3203') and datadate<='2021-05-25' GROUP BY substring(datadate,1,4),org_code,index_code ORDER BY substring(datadate,1,4) desc) t where
t.datadate1=y.datadate and t.org_code1=y.org_code and t.index_code1=y.index_code ORDER BY y.org_code,y.datadate desc
select * from (select * from (select max(datadate) as datadate1,org_code as org_code1,index_code as index_code1 from "APP_DM_SCHEMA".lsds_apply where index_code in ('02040200045','12040200059','1204020060','12040200025') and org_code='F3202' and datadate