MyTetra Share
Делитесь знаниями!
Пересечение периодов дат
Время создания: 24.03.2021 10:06
Раздел: INFO - Development - DATABASE - postgres
Запись: wwwlir/Tetra/master/base/16165515749lyonr8vu6/text.html на raw.githubusercontent.com

(select

count(vcre.id)

from

rtneo_contragent_real_estate vcre

where

vcre.real_estate_id = re.id

and vcre.delete_ts is null

and vcre.id <> cre1.id

and (vcre.own_type = 2 or vcre.own_type = 3)

and (coalesce(vcre.validity_from, '2000-01-01')::timestamptz<coalesce(cre1.validity_to, '2030-12-31'::timestamptz)

and coalesce(vcre.validity_to, '2030-12-31')::timestamptz>coalesce(cre1.validity_from, '2000-01-01')::timestamptz)

) != 0


and (coalesce(cre1.validity_from, '2019-01-01 0:00:00-00'), coalesce(cre1.validity_to, '2030-12-31 0:00:00-00'))

overlaps

((select min(coalesce(d1_cre.validity_from, '2019-01-01 0:00:00-00'))

from rtneo_contragent_real_estate d1_cre

where d1_cre.real_estate_id = re.id and d1_cre.delete_ts is null and d1_cre.id <> cre1.id),

(select max(coalesce(d2_cre.validity_to, '2030-12-31 0:00:00-00'))

from rtneo_contragent_real_estate d2_cre

where d2_cre.real_estate_id = re.id and d2_cre.delete_ts is null and d2_cre.id <> cre1.id))

Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования