Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- upper(grbs.full_name) As grbsname,
- contr.inn,
- Case When pp.delegated is true Then upper(grbs.full_name) Else upper(contr.full_name) End As customername,
- Case When pp.delegated is true Then grbs.inn Else contr.inn End As customerinn,
- contr.full_name,
- cuf.mismatch_info_text,
- document_type,
- l.id,
- cc.contract_rnk,
- cc.date_sign As contractsigndate
- FROM control_99 as c
- Inner join control_99_ue_failed_checks_info cuf on c.id=cuf.control99_id
- Inner join cm_contracts as cc on cc.contract_rnk=c.control_object_number
- Inner Join public.contragents contr On (contr.id = cc.contract_customer)
- 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))
- Inner Join public.procedures pr On (l.procedure_id = pr.id And pr.actual = true)
- Inner Join public.po_procedures pp On (pp.procedure_id = pr.id)
- Left Join public.po_list_org_hierarchy ploh On (ploh.contragent_id = cc.contract_customer and ploh.parent_type = 1 and ploh.actual = true)
- Left join (Select c_grbs.id,c_grbs.full_name,c_grbs.inn,c_grbs.kpp,gcgrbs.code
- From contragents c_grbs
- Left Join gpospb_contragents gcgrbs On (gcgrbs.contragent_id = c_grbs.id)
- )grbs On (grbs.id = ploh.parent_contragent_id)
- where cuf.mismatch_info_text is not null
- order by cc.date_sign desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement