В таблице
create table quiz1 (
id integer
,marker integer
,str varchar2(30)
,constraint quiz1_pk primary key (id,marker)
)
найти sql запросом те marker, у которых конкатенация str в порядке возрастания id содержит :match_string?
Усложнение 1:
Найти marker и id этих записей
Усложнение 2:
Вывести то же самое, но на таблице, где str заменен на val number, а проверить нужно sys.odcinumberlist в том же порядке в значениях val упорядоченных по id:
create table quiz1 (
id integer
,marker integer
,val number
,constraint quiz1_pk primary key (id,marker)
)
Усложнение 3:
Поиграйтесь в таком же духе с анализом шахматных партий, можно отдельно для черных и белых:
«Click to show Spoiler - click again to hide...»
with chesslog as (
select 1 party_id,1 step,'E' x1, 2 y1,'E' x2, 4 y2 from dual union all
select 1,2,'D',7,'D',5 from dual union all
select 1,3,'E',4,'D',5 from dual union all
select 1,4,'D',8,'D',5 from dual union all
select 1,5,'B',1,'C',3 from dual union all
select 1,6,'D',5,'D',8 from dual union all
select 1,7,'D',2,'D',4 from dual union all
select 1,8,'E',7,'E',6 from dual union all
select 1,9,'G',1,'F',3 from dual union all
select 1,10,'G',8,'F',6 from dual union all
select 1,11,'F',1,'D',3 from dual union all
select 1,12,'F',8,'E',7 from dual union all
select 1,13,'E',1,'G',1 from dual union all
select 1,14,'E',8,'G',8 from dual union all
select 1,15,'C',1,'E',3 from dual union all
select 1,16,'B',7,'B',6 from dual union all
select 1,17,'F',3,'E',5 from dual union all
select 1,18,'C',8,'B',7 from dual union all
select 1,19,'F',2,'F',4 from dual union all
select 1,20,'B',8,'D',7 from dual union all
select 1,21,'D',1,'E',2 from dual union all
select 1,22,'F',6,'D',5 from dual union all
select 1,23,'C',3,'D',5 from dual union all
select 1,24,'E',6,'D',5 from dual union all
select 1,25,'F',1,'F',3 from dual union all
select 1,26,'F',7,'F',5 from dual union all
select 1,27,'F',3,'H',3 from dual union all
select 1,28,'G',7,'G',6 from dual union all
select 1,29,'G',2,'G',4 from dual union all
select 1,30,'F',5,'G',4 from dual union all
select 1,31,'H',3,'H',7 from dual union all
select 1,32,'D',7,'E',5 from dual union all
select 1,33,'F',4,'E',5 from dual union all
select 1,34,'G',8,'H',7 from dual union all
select 1,35,'E',2,'G',4 from dual union all
select 1,36,'F',8,'G',8 from dual union all
select 1,37,'G',4,'H',5 from dual union all
select 1,38,'H',7,'G',7 from dual union all
select 1,39,'H',5,'H',6 from dual union all
select 1,40,'G',7,'F',7 from dual union all
select 1,41,'H',6,'H',7 from dual union all
select 1,42,'F',7,'E',6 from dual union all
select 1,43,'H',7,'H',3 from dual union all
select 1,44,'E',6,'F',7 from dual union all
select 1,45,'A',1,'F',1 from dual union all
select 1,46,'F',7,'E',8 from dual union all
select 1,47,'H',3,'E',6 from dual union all
select 1,48,'G',8,'G',7 from dual union all
select 1,49,'E',3,'G',5 from dual union all
select 1,50,'D',8,'D',7 from dual union all
select 1,51,'D',3,'G',6 from dual union all
select 1,52,'G',7,'G',6 from dual union all
select 1,53,'E',6,'G',6 from dual union all
select 1,54,'E',8,'D',8 from dual union all
select 1,55,'F',1,'F',8 from dual union all
select 1,56,'D',7,'E',8 from dual union all
select 1,57,'G',6,'E',8 from dual union all
select 1,58,'#',null,null,null from dual
union all
select 2,1,'E',2,'E',4 from dual union all
select 2,2,'E',7,'E',5 from dual union all
select 2,3,'G',1,'F',3 from dual union all
select 2,4,'B',8,'C',6 from dual union all
select 2,5,'F',1,'C',4 from dual union all
select 2,6,'F',8,'C',5 from dual union all
select 2,7,'B',2,'B',4 from dual union all
select 2,8,'C',5,'B',4 from dual union all
select 2,9,'C',2,'C',3 from dual union all
select 2,10,'B',4,'C',5 from dual union all
select 2,11,'E',1,'G',1 from dual union all
select 2,12,'D',7,'D',6 from dual union all
select 2,13,'D',2,'D',4 from dual union all
select 2,14,'C',5,'B',6 from dual union all
select 2,15,'A',2,'A',4 from dual union all
select 2,16,'G',8,'F',6 from dual union all
select 2,17,'C',4,'B',5 from dual union all
select 2,18,'A',7,'A',6 from dual union all
select 2,19,'B',5,'C',6 from dual union all
select 2,20,'B',7,'C',6 from dual union all
select 2,21,'A',4,'A',5 from dual union all
select 2,22,'B',6,'A',7 from dual union all
select 2,23,'D',4,'E',5 from dual union all
select 2,24,'F',6,'E',4 from dual union all
select 2,25,'D',1,'E',2 from dual union all
select 2,26,'D',6,'D',5 from dual union all
select 2,27,'F',3,'D',4 from dual union all
select 2,28,'E',4,'C',3 from dual union all
select 2,29,'B',1,'C',3 from dual union all
select 2,30,'A',7,'D',4 from dual union all
select 2,31,'E',2,'D',3 from dual union all
select 2,32,'C',6,'C',5 from dual union all
select 2,33,'D',3,'G',3 from dual union all
select 2,34,'C',8,'E',6 from dual union all
select 2,35,'C',1,'G',5 from dual union all
select 2,36,'D',8,'D',7 from dual union all
select 2,37,'A',1,'C',1 from dual union all
select 2,38,'F',7,'F',6 from dual union all
select 2,39,'E',5,'F',6 from dual union all
select 2,40,'G',7,'F',6 from dual union all
select 2,41,'G',5,'F',4 from dual union all
select 2,42,'H',8,'G',8 from dual union all
select 2,43,'G',3,'F',3 from dual union all
select 2,44,'E',8,'C',8 from dual union all
select 2,45,'F',1,'E',1 from dual union all
select 2,46,'C',5,'C',4 from dual union all
select 2,47,'F',3,'E',2 from dual union all
select 2,48,'E',6,'F',5 from dual union all
select 2,49,'E',2,'A',2 from dual union all
select 2,50,'G',8,'G',2 from dual union all
select 2,51,'G',1,'H',1 from dual union all
select 2,52,'G',2,'F',2 from dual union all
select 2,53,'#',null,null,null from dual
)
select *
from chesslog
order by 1,2
ЗЫ. Поиск по stragg всех записей считаю неинтересным прожорливым решением
Comments
Отправить комментарий