Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
556 B
1
Indexable
Never
	 DROP TABLE IF EXISTS #reg --существующие клиенты наши (пропусков в данных нет) из МО
	 SELECT 
		s.client_inn, 
		s.client_name, 
		s.holding_name, 
		s.contract_number, 
		s.doc_reg_number, 
		cc.organization_department AS OTDELENIE, 
		cc.counterparty_name,
		cc.inn AS client_inn_2,
		s.MAX_DOC_DATE_MO
	 INTO #reg
	 FROM #whg s
	 LEFT JOIN  [DATAMARTS].[ASKU_RP].[vw_counterparty_contract_segment] cc --контракт
	 ON s.contract_number = cc.contract_number AND s.client_inn = cc.inn 
Leave a Comment