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 |

相关推荐
wangbaowo3 分钟前
MySQL数据库下篇
数据库·经验分享·笔记·学习·mysql·安全
ABdolphin6 分钟前
Spring-博客系统项目
数据库·sql·spring
伤不起bb13 分钟前
MySQl 数据库操作
数据库·mysql
是店小二呀1 小时前
【金仓数据库征文】金仓数据库(KingbaseES)迁移与集群部署实战:从MySQL到KES的全流程解析
数据库·mysql·金仓数据库 2025 征文·数据库平替用金仓
一只专注api接口开发的技术猿1 小时前
1688 API 自动化采集实践:商品详情实时数据接口开发与优化
大数据·运维·数据库·自动化
昔我往昔1 小时前
MySQL中为什么使用B+树结构、B+树和普通的平衡树的区别
数据库·b树·mysql
翁正存2 小时前
MySQL为什么选择B+树
数据库·b树·mysql
码农黛兮_462 小时前
MySQL 数据库集群部署、性能优化及高可用架构设计
数据库·mysql·性能优化
AllenO.o3 小时前
Redis五种数据结构详解
java·数据结构·数据库·redis·缓存
消失在人海中3 小时前
数据分析基础:需要掌握的入门知识
数据库·人工智能·数据分析