查询oracle数据库2个时间段之间缺少哪天
时间: 2024-02-15 09:02:44 浏览: 147
你可以通过以下SQL语句查询oracle数据库2个时间段之间缺少哪天:
```
WITH all_dates AS (
SELECT TRUNC(start_date) + LEVEL - 1 AS date
FROM (
SELECT MIN(start_date) AS start_date, MAX(end_date) AS end_date
FROM your_table
)
CONNECT BY LEVEL <= end_date - start_date + 1
)
SELECT *
FROM all_dates
WHERE date NOT IN (
SELECT TRUNC(date_column)
FROM your_table
WHERE date_column BETWEEN start_date AND end_date
)
ORDER BY date;
```
在以上SQL语句中,你需要将 "your_table" 替换为你的表名, "start_date" 和 "end_date" 替换为你的时间段的起始时间和结束时间。运行以上SQL语句后,将会返回在时间段内缺失的日期。
阅读全文