WITH data_set AS (
SELECT is_running, datetime
FROM
(
SELECT is_running, datetime, row_number() over (ORDER BY DATETIME DESC) rn
FROM mon_host_stat_hist
WHERE institution_id='TUB' and host = 'Client'
)
WHERE rn = 1;
)
SELECT
datetime, next_datetime, (next_datetime-datetime) as diff
FROM
(
SELECT
datetime,
lead(datetime, 1, null) OVER (ORDER BY datetime) AS next_datetime,
FROM data_set
)datetime,
lead(datetime, 1, null) OVER (ORDER BY datetime) AS next_datetime,
FROM data_set
Hiç yorum yok:
Yorum Gönder