|
|||||||
Testing with union
Время создания: 13.10.2020 16:49
Раздел: INFO - Development - DATABASE - postgres
Запись: wwwlir/Tetra/master/base/1602578961943wn120ic/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
with res as( select distinct cts.* from ( select rct.* from (rtneo_contract rc join rtneo_contragent rct on rc.contragent_id = rct.id) where (rc.delete_ts is null and rct.delete_ts is null) and rc."template" = 'MSG310820' union select rct.* from rtneo_contragent rct join rtneo_entityes_temporary_set rets2 on rct.id = rets2.entity_id where rct.delete_ts is null and rets2.delete_ts is null and rets2.entity_name = 'Contragent') as cts) select * from ( select 1 as num, 'deleted', count(*)::text, (count(*) = 0) from res where delete_ts is not null union select 2, 'count', count(*)::text, (count(*) > 0) from res where delete_ts is null union select 3, 'no contracts', count(r)::text, (count(*) = 0) from res r left outer join rtneo_contract rc2 on r.id = rc2.contragent_id where rc2.delete_ts is null and rc2 is null union select 4, 'check', (1)::text as num, (1=1) from res where delete_ts is null union select 5, 'check', true::text, (true = false) from res where delete_ts is null ) as test order by num; |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|