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 |

相关推荐
爱吃面条的猿23 分钟前
MySQL 随机日期/时间生成
数据库·mysql
2501_9399090528 分钟前
Mysql 主从复制、读写分离
数据库·mysql
潇湘秦36 分钟前
ORACLE_PDB_SID和ORACLE_SID的区别
数据库·oracle
0***86331 小时前
SQL Server2019安装步骤+使用+解决部分报错+卸载(超详细 附下载链接)
javascript·数据库·ui
wstcl1 小时前
通过EF Core将Sql server数据表移植到MySql
数据库·mysql·sql server·efcore
聪聪那年221 小时前
Oracle 11g windows 10安装与卸载
数据库·oracle
前端之虎陈随易1 小时前
MoonBit内置数据结构详解
数据结构·数据库·redis
云和恩墨2 小时前
AI驱动的Oracle SQL优化:从经验依赖到智能协同的三大价值
人工智能·sql·oracle·深度优先·dba
小二·2 小时前
Spring框架入门:TX 声明式事务详解
java·数据库·spring
万邦科技Lafite2 小时前
一键获取淘宝店铺所有商品信息,实时监控商品数据
开发语言·数据库·python·api·开放api·电商开放平台·淘宝开放平台