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 |

相关推荐
薛晓刚32 分钟前
哪个领域数据库最难替换?
数据库
RainbowSea38 分钟前
14. MySQL 锁的详细说明
java·sql·mysql
芷栀夏1 小时前
基于Anything LLM的本地知识库系统远程访问实现路径
数据库·人工智能
RainbowSea1 小时前
12 MySQL 数据库其它调优策略
java·sql·mysql
软件2051 小时前
【redis使用场景——缓存——数据淘汰策略】
数据库·redis·缓存
ChinaRainbowSea1 小时前
9-2 MySQL 分析查询语句:EXPLAIN(详细说明)
java·数据库·后端·sql·mysql
时序数据说1 小时前
Java类加载机制及关于时序数据库IoTDB排查
java·大数据·数据库·物联网·时序数据库·iotdb
deeper_wind1 小时前
MySQL数据库基础(小白的“升级打怪”成长之路)
linux·数据库·mysql
加勒比海涛2 小时前
Spring Cloud Gateway 实战:从网关搭建到过滤器与跨域解决方案
数据库·redis·缓存
belldeep2 小时前
java:如何用 JDBC 连接 TDSQL 数据库
java·数据库·jdbc·tdsql