sql查询最新数据

该博客内容涉及复杂的SQL查询操作,包括子查询、聚合函数和分组,主要用于从特定数据表中筛选和提取特定指数代码和组织代码的数据。查询涉及到日期范围限制,并对结果进行排序,展示了对数据库管理和数据提取的深入理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值