Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- o.inn,
- o.kpp,
- o.ogrn,
- o.fullname--, u.username, concat_ws(' ',u.lastname, u.firstname, u.middlename) as name
- ,
- 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 год дала Анпилова
- count(distinct om.userid)
- from organization As o
- 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'
- 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 registrationstatusid Is Null
- --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 5,6 desc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement