sql 查询

连续区域取数

select sid,min(b.eid) as eid from

(select id+2 as sid from txtTempTable where tc1 like 'Name*') as a,

(select id as eid from txtTempTable where tc1='Page') as b

where sid<b.eid

group by sid

16,18, 22,23

|----|-----|-----|
| id | tc1 | tc2 |
| 16 | | |
| 17 | | |
| 18 | | |
| 22 | | |
| 23 | | |

两表对应关联

select aa.sid,aa.eid,

(select top 1 tc2 from txtTempTable where tc1 like "Analyte*" and id>aa.sid-14 and id<aa.eid)

as xmmc from

(

select sid,min(b.eid) as eid from

(select id+2 as sid from txtTempTable where tc1 like 'Name*') as a,

(select id as eid from txtTempTable where tc1='Page') as b

where sid<b.eid

group by sid

) as aa

|-----|-----|-----|
| sid | eid | mc |
| 16 | 18 | f01 |
| 22 | 23 | f02 |

相关推荐
邮专薛之谦15 小时前
MySQL 完整SQL指令大全(含详细解释+实战示例)
数据库·sql·mysql
YL2004042615 小时前
MySQL-进阶篇-SQL优化
数据库·sql·mysql
Irissgwe15 小时前
redis之典型应用-缓存cache
数据库·redis·缓存·缓存击穿·缓存雪崩·redis淘汰策略
Shely201716 小时前
数据库索引
数据库·mysql
我也不曾来过116 小时前
Mysql
数据库·mysql
小陈工16 小时前
Python异步编程进阶:asyncio高级模式与性能调优
开发语言·前端·数据库·人工智能·python·flask·numpy
gQ85v10Db16 小时前
Redis分布式锁进阶第三十一篇
数据库·redis·分布式
身如柳絮随风扬16 小时前
购物车服务设计:基于 Redis Hash 的高效实现
数据库·redis
观测云16 小时前
观测云4月产品升级报告 | 统一目录、Obsy AI 全新上线,基础设施、场景、监控告警、管理多项能力升级
数据库·人工智能·可观测性·产品迭代·观测云
Mike117.16 小时前
GBase 8c schema 和 search_path 引发的对象定位问题
数据库·sql·oracle