Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- o.inn,
- o.kpp,
- o.ogrn,
- o.fullname,
- count(distinct u.id)
- from organization As o
- Inner join nsi_okopf n On n.id = o.legalformid And n.id In (175,174,173)
- Left join organizationmember As om On o.id = om.organization_id
- Left join users u on om.userid = u.id and u.active = False
- Where 1=1
- And actual_id Is Null
- -- And registrationstatusid Is Null
- And external_customer = True
- -- and o.inn='7841326892'
- -- and o.id in (select organization_id from organizationmember where id in (select memberid from organizationmemberrole where roleid = 44) group by organization_id)
- Group By o.inn, o.kpp, o.ogrn, o.fullname
- Order by 6 desc;
- Select
- count(distinct o.inn)
- From public.organization o
- inner join public.procedures p on o.id = p.customer_id
- inner join contract_eshop.eshop_notice n on p.id = n.external_id::integer
- inner join contract_eshop.contract c on n.id = c.notice_id and c.status_id in (13,14,15,16,18,22)
- Inner Join contract_eshop.contract_sign As s On (c.sign_id=s.id And c.actual_id Is Null And s.actual_id Is Null)
- where 1=1
- and inn in ('4719018491', '5321144148', '7801109098', '7801119530', '7801395709', '7801396325', '7801396808', '7801397022', '7801397921', '7802119596', '7802120714', '7802122503', '7802174170', '7802232256', '7802339560', '7802340269', '7802341103', '7804075954', '7804077091', '7804077197', '7804077461', '7804077574', '7804086603', '7804170260', '7804327062', '7804328852', '7804330403', '7804331598', '7805111700', '7805300419', '7805371900', '7805384634', '7805384761', '7805386021', '7805386825', '7805387120', '7805387297', '7806055664', '7806056675', '7806114704', '7806328287', '7806328551', '7806330053', '7807027846', '7807028374', '7807310726', '7807310885', '7807310892', '7807310966', '7807311102', '7810032780', '7810050080', '7810149259', '7810248186', '7810258787', '7811073027', '7811075000', '7811077127', '7811077945', '7811140940', '7811332433', '7811333821', '7811334127', '7811334261', '7811334857', '7813335775', '7813337268', '7813337275', '7813337557', '7813337860', '7813338769', '7813478090', '7813627295', '7814086602', '7814088960', '7814128901', '7814308245', '7814316670', '7814333072', '7814333890', '7814334950', '7814732937', '7814770844', '7816142620', '7816228242', '7816375800', '7816377413', '7816381321', '7816382452', '7817031760', '7817032115', '7817304520', '7817304538', '7817304591', '7817304658', '7818008764', '7819019663', '7819019670', '7819020524', '7819021782', '7819024159', '7819025258', '7819032921', '7819301317', '7820023424', '7820029539', '7820035050', '7820305475', '7820325792', '7822005565', '7823005712', '7825124200', '7825442740', '7825453050', '7825454657', '7825691873', '7826029158', '7826096732', '7826691202', '7826692630', '7826704155', '7827009884', '7827009972', '7827012478', '7827012541', '7838339997', '7839007722', '7839327088', '7840310716', '7840328382', '7841326892', '7842006310', '7842019414', '7843300402', '7843301614', '7843301861', '7843302551', '7843302689', '7843302706', '7843302720', '7843302784', '7843302826');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement