Advertisement
GLASHATAY_007

99/5.1

Feb 1st, 2023
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT  
  2.                 upper(grbs.full_name) As grbsname,
  3.                 contr.inn,
  4.         Case When pp.delegated is true Then upper(grbs.full_name) Else upper(contr.full_name) End As customername,
  5.                 Case When pp.delegated is true Then grbs.inn Else contr.inn End As customerinn,
  6.                 contr.full_name,
  7.         cuf.mismatch_info_text,
  8.                 document_type,
  9.                 l.id,
  10.                 cc.contract_rnk,
  11.                 cc.date_sign As contractsigndate
  12. FROM  control_99 as c
  13. Inner join control_99_ue_failed_checks_info cuf on c.id=cuf.control99_id
  14. Inner join cm_contracts as cc on cc.contract_rnk=c.control_object_number
  15. Inner Join public.contragents contr On (contr.id = cc.contract_customer)
  16. Inner Join public.lots l On (l.id = cc.lot_id And l.actual = true And (cc.contract_rnk Is Not Null Or cc.external_id Is Not Null) and cc.id not in (150039,81681,70830,91739,104632,215242,216796,217707,217712,217795,219368,240051,624804))
  17. Inner Join public.procedures pr On (l.procedure_id = pr.id And pr.actual = true)
  18. Inner Join public.po_procedures pp On (pp.procedure_id = pr.id)
  19. Left Join public.po_list_org_hierarchy ploh On (ploh.contragent_id = cc.contract_customer and ploh.parent_type = 1 and ploh.actual = true)
  20. Left join (Select c_grbs.id,c_grbs.full_name,c_grbs.inn,c_grbs.kpp,gcgrbs.code
  21.                      From contragents c_grbs
  22.                      Left Join gpospb_contragents gcgrbs On (gcgrbs.contragent_id = c_grbs.id)
  23.                     )grbs On (grbs.id = ploh.parent_contragent_id)
  24.  where cuf.mismatch_info_text is not null
  25.  order by cc.date_sign desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement