83 lines
4.0 KiB
SQL
83 lines
4.0 KiB
SQL
--select count(distinct cod_fiscale) from c6martperiodico.rischio_aggregato
|
|
--select * from c6martperiodico.scarti
|
|
-- FARE FUNZIONE GETPREVTRIMESTRE PER LA DATA DI REVOCA
|
|
--select c6martperiodico.gettrimestre2(getdate(),0)
|
|
--select c6martperiodico.gettrimestre2(getdate(),1)
|
|
--select * from [C6MartPeriodico].[vContrattiPerGenerazioneReport]
|
|
--select count(*) from [C6MartPeriodico].[vContrattiPerGenerazioneReport]
|
|
--select count(*) from [C6MartPeriodico].gestione_pdf_ftp where dataGenerazione > c6martperiodico.gettrimestre2(getDate(),1)
|
|
--select count(*) from [C6MartPeriodico].[vContrattiPerGenerazioneReport] where freq_diagnosi is not null
|
|
--select c6martperiodico.gettrimestre2(c6martperiodico.gettrimestre2(getdate(),1),0)
|
|
CREATE VIEW [C6MartPeriodico].[vControlliFabio]
|
|
AS
|
|
SELECT
|
|
distinct --top 2000
|
|
C6.Rete, C6.Cod_Agente, C6.Cod_Fiscale, C6.CodiceContratto, C6.Freq_Monitor, C6.Freq_Diagnosi,
|
|
data_fineAvanzato--,pdf.dataGenerazione
|
|
FROM C6Mart.CONTRATTOSEI AS C6
|
|
INNER JOIN C6Mart.GESTIONE_PDF_FTP AS PDF ON C6.Rete = PDF.Rete AND C6.Cod_Fiscale = PDF.CodiceFiscale AND
|
|
C6.CodiceContratto = SUBSTRING(PDF.NomeFile, 1, 11) --SUBSTRING(PDF.NomeFile, 0, 12)
|
|
/* */ inner JOIN c6Martperiodico.Mifid AS mi ON c6.rete=mi.rete AND c6.cod_fiscale=mi.cod_fiscale
|
|
-- join c6stagingperiodico.spb_contr_sintesi bf on c6.rete = bf.rete and c6.cod_fiscale = bf.codfis
|
|
/* */ inner join c6martperiodico.patrimonio_bf bf on c6.rete = bf.rete and c6.cod_fiscale = bf.cod_fiscale
|
|
--includi campione
|
|
/* */ --INNER JOIN dbo.CampioneReport AS t ON t.Cod_fiscale = C6.Cod_Fiscale AND t.Rete = C6.Rete
|
|
--INNER JOIN c6martperiodico.selezionecampione_lele200 AS t ON t.Cod_fiscale = C6.Cod_Fiscale AND t.Rete = C6.Rete
|
|
WHERE (1 = 1)
|
|
--AND ISNULL(C6.Data_FineAvanzato, CAST('99991231' AS datetime)) > '20111231' /*Precedente Trimestrale*/ --select c6martperiodico.gettrimestre2(c6martperiodico.gettrimestre2(getdate(),1),0)
|
|
AND ISNULL(C6.Data_FineAvanzato, CAST('99991231' AS datetime)) > '20120331' /*Precedente Trimestrale*/ --select c6martperiodico.gettrimestre2(c6martperiodico.gettrimestre2(getdate(),1),0)
|
|
--V commentare nel giro email
|
|
/* */ and isnull(mi.scaduto,1) = 0
|
|
and PDF.DataGenerazione < c6martperiodico.gettrimestre2(getdate(),1) --'20110301'
|
|
-- AND isnull(C6.Data_Invio_Monitoraggio_Trimestrale,cast('20091101' as datetime)) < c6martperiodico.gettrimestre2(getdate(),0)--'20110331' --cast(C6MartPeriodico.getTrimestre(GETDATE(), 0) as datetime)
|
|
--and C6.cod_fiscale IN ('RSSPCD43P12A056Z')
|
|
--('PPSRNG57M61A217K', 'ZNCLSE35M71L840K', 'TRVSBN38R52F839X', 'LLAMGH27A43M058H')
|
|
-- and C6.cod_fiscale IN (
|
|
--
|
|
----'ZNCLSE35M71L840K'
|
|
--'PPSRNG57M61A217K',
|
|
--
|
|
--'LLAMGH27A43M058H',
|
|
--
|
|
--'CVARSO23C41B551C'
|
|
--
|
|
--
|
|
--'DBNMLS66H43A182U',
|
|
--'DLMFRZ38D50I728S',
|
|
--'LZZRNN46M71F130V',
|
|
--'BNSNRC50H09I207Z',
|
|
--'LNDNMR27B63D612R',
|
|
--'BBNMSM66H10L219F',
|
|
--'BCCLDR33D16H501R',
|
|
--'CSTPLA48C26H361L',
|
|
--'GNDLCU30C68D205Z',
|
|
--'MTTRND49P17I927W',
|
|
--'RSLREU41B12D809F',
|
|
--'CSTPLA48C26H361L',
|
|
--'RSLREU41B12D809F',
|
|
--'00101930519',
|
|
--'BCCGPL51P30D969V',
|
|
--'00101930519',
|
|
--'94009110068',
|
|
--'94033640015',
|
|
--'97176630156',
|
|
--'BAAMTR48C43I470Y'
|
|
--)
|
|
--and C6.cod_fiscale IN ('LZZRNN46M71F130V')--LNDNMR27B63D612R')
|
|
--and C6.cod_fiscale IN ('BRNGZN59C06C901O', 'BLTRNZ48M02F269I') --'GZZSLD52E20G869L')
|
|
--and C6.cod_fiscale IN ('SDRFNC66T45D451P')--, 'VRRCLN23R50L847X')
|
|
--stampa campione per dipartimento
|
|
--and (provenienza = 'QC')
|
|
--STAMPO SOLO CHI HA DIAGNOSI and c6.Freq_Diagnosi is not null
|
|
--AND isnull(C6.Data_Invio_Monitoraggio_Trimestrale,cast('20091101' as datetime)) < c6martperiodico.gettrimestre2(getdate(),0)--'20110331' --cast(C6MartPeriodico.getTrimestre(GETDATE(), 0) as datetime)
|
|
--and
|
|
--mi.rete is null
|
|
--or
|
|
--bf.rete is null
|
|
--)
|
|
--AND C6.COD_FISCALE IN (
|
|
--'BCCDCE46S22I068J',
|
|
--'BCCDIA28B59E933Z')
|
|
--DA VALERIO CONTROLLA CHE RITORNI IL TRIMESTRE DI MARZO
|
|
--select c6martperiodico.gettrimestre2(getdate(),1)
|
|
--select * from campioneReport |