SET QUOTED_IDENTIFIER ON;
-- create
CREATE TABLE entity (
xml ntext
);
-- insert
INSERT INTO entity(xml) VALUES ('<r><authCard>abc123slip4</authCard><authCard>abc1234</authCard></r>');
-- fetch
SELECT * FROM entity
where cast(xml as xml).value('(/r/authCard)[1]', 'nvarchar(max)') LIKE N'%slip%'; WITH RECURSIVE
-- Тестовая выборка. Если есть "живая" таблица, то эту выборку можно убрать
t as (select 10.000 value union
select 10.001 union
select 10.002 union
select 10.003 union
select 10.005 union
select 10.009 -- специально добавил контр. пример
),
-- Таблица-генератор последовательности чисел от min(t.value) до max(t.value) с шагом 0.001 с помощью CTE (есть ограничение по глубине рекурсии!)
num_series AS (
SELECT (select min(value) from t) AS num
UNION ALL
SELECT num + 0.001 FROM num_series
WHERE num < (select max(value) from t)
)
-- Запрос, в котором сопоставляем таблицу генератор и исходную таблицу, чтобы найти недостающие кванты
SELECT *
FROM num_series
where not exists(select t.value from t where t.value = num_series.num)
and num_series.num >= 10.000-- Тестовая выборка
with t as (select to_date('2024-09-17 11:52:17', 'yyyy-mm-dd hh24:mi:ss') begin_date, to_date('2024-12-17 11:52:17', 'yyyy-mm-dd hh24:mi:ss') end_date, 3 Cnt from dual union
select to_date('2024-06-10 14:52:19', 'yyyy-mm-dd hh24:mi:ss') begin_date, to_date('2024-07-10 14:52:19', 'yyyy-mm-dd hh24:mi:ss') end_date, 1 Cnt from dual)
-- Иерархический запрос
select distinct T.*,
add_Months(T.Begin_Date, Level - 1) as Current_Date, -- отсчет месяцев
Level as Current_Val -- текущее значение отсчета
from T
CONNECT BY add_Months(T.Begin_Date, Level) <= T.End_Date
order siblings by T.Begin_Date desc select *
from cst
where exists( select *
from cst_stat
where cst.id = cst_stat.cst_id
and cst_stat.p_key = 5 and cst_stat.p_value = 1.5
) -- вариант поиска в JSON значения 5: 1.5