Случайно группой не ошибся?
Этот вопрос относится к пониманию SQL, а не конкретко к Firebird


1) С использованием Execute block, можно тоже самое но с SP
execute block (d date = :d)
returns (h int, t int)
as
declare variable d1 timestamp;
declare variable d2 timestamp;
begin
  h = 0;
  while (h < 24) do
  begin
    d1 = d + h / 24.000;
    d2 = d + (h+1) / 24.000;
    t = null;
    select min(t)
    from table1 where date_table >= :d1 and date_table < :d1
    into t;
    suspend;
    h = h + 1;
  end
end;


2) В этом случае не покажутся пустые часы
select extract(hours from date_table), min(t)
from table1 t
group by 1

Ответить