-- Тестовая выборка
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
Программу запускал, но за 20 минут она не сдвинулась.
Сейчас запустил без него и проверка прошла моментально
select S.*,
(select S1.location from services S1 where S1.main = S.main and (S1.list is null or S1.list = '')) head_index
from services S
order by head_index, S.list is null or S.list = '' desc, S.location is null or S.location = '' desc, S.location
$sql = "select S.*,
(select S1.location from services S1 where S1.main = S.main and (S1.list is null or S1.list = '')) head_index
from services S
order by head_index, S.list is null or S.list = '' desc, S.location is null or S.location = '' desc, S.location";
$res = mysqli_query($conn, $sql);
$cat_index = 0;
while($row = msqli_fetch_assoc($res))
{
if(is_null($row['list']))
{
if($cat_index > 0)
echo '</ul>'; // закрытие списка
echo '<p>'.$row['main'].'</p><ul>'; // название категории, начало списка
$cat_index++; // считаем категорию, чтобы правильно закрывать списковые теги
}
else
{
echo '<li>'.$row['list'].'</li>';
}
}
if($cat_index > 0)
echo '</ul>'; // закрытие списка
Уже пробовал три фирмы - Старт, Гарнизон, Buro - наши отечественные.