Advertisement
GLASHATAY_007

муниципальные заказчики

Jun 27th, 2024
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     select
  2.         o.inn,
  3.         o.kpp,
  4.         o.ogrn,
  5.         o.fullname--, u.username, concat_ws(' ',u.lastname, u.firstname, u.middlename) as name
  6.         ,
  7.         case when o.inn in ('7822002853', '7811040938', '7838339997', '7840411560', '7842353970', '7819042736', '7811351651', '7843301614', '7841326892', '7807335262', '7805111700', '7805403679', '7820321438', '7817326228', '7838332649', '7814347935') then 'ДА' ELSE 'НЕТ' END CUST_2024, -- список на 2024 год дала Анпилова
  8.         count(distinct om.userid)
  9.     from organization As o
  10.     Inner join nsi_okopf n On n.id = o.legalformid And n.id In (175,174,173) And actual_id Is Null And external_customer = True and o.type='customer'
  11.     Left join organizationmember As om On o.id = om.organization_id
  12.     left join users u on om.userid = u.id and u.active = False
  13.     Where 1=1
  14.      --And registrationstatusid Is Null
  15.      --and o.inn='7841326892'
  16.     --and o.id in (select organization_id from organizationmember where id in (select memberid from organizationmemberrole where roleid = 44) group by organization_id)
  17. Group By o.inn, o.kpp, o.ogrn, o.fullname
  18. Order by 5,6 desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement