By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
with
projects (project_id, year_construction) as (
select 1, 2022 from dual union all
select 2, 2023 from dual union all
select 3, 2024 from dual union all
select 4, 2025 from dual
),
project_finances (project_id, year_funding) as (
select 1, 2022 from dual union all
select 2, 2022 from dual union all
select 2, 2023 from dual union all
select 3, 2025 from dual
)
select *
from projects p
WHERE EXISTS(
SELECT 1
FROM project_finances f
GROUP BY f.project_id
HAVING COUNT(CASE f.year_funding WHEN p.year_construction THEN 1 END) = 0
AND p.project_id = f.project_id
)
PROJECT_ID | YEAR_CONSTRUCTION |
---|---|
3 | 2024 |