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 |

相关推荐
vvvae12345 小时前
分布式数据库
数据库
雪域迷影6 小时前
PostgreSQL Docker Error – 5432: 地址已被占用
数据库·docker·postgresql
bug菌¹6 小时前
滚雪球学Oracle[4.2讲]:PL/SQL基础语法
数据库·oracle
逸巽散人7 小时前
SQL基础教程
数据库·sql·oracle
月空MoonSky7 小时前
Oracle中TRUNC()函数详解
数据库·sql·oracle
momo小菜pa7 小时前
【MySQL 06】表的增删查改
数据库·mysql
向上的车轮8 小时前
Django学习笔记二:数据库操作详解
数据库·django
编程老船长8 小时前
第26章 Java操作Mongodb实现数据持久化
数据库·后端·mongodb
Mephisto.java8 小时前
【力扣 | SQL题 | 每日四题】力扣2082, 2084, 2072, 2112, 180
sql·算法·leetcode
全栈师9 小时前
SQL Server中关于个性化需求批量删除表的做法
数据库·oracle