-- Schema: C6MartPeriodico -- Stored Procedure: Estrazione_Campione_Cruscotto CREATE procedure [C6MartPeriodico].[Estrazione_Campione_Cruscotto] AS BEGIN drop table if exists C6MartPeriodico.TB_Estrazione_Campione_Cruscotto select top(1) rete,codice_fiscale,'Cliente W Retail (Non Professionale) con solo Monitoraggio' as Nota into C6MartPeriodico.TB_Estrazione_Campione_Cruscotto from c6martperiodico.rp_tb_tipologia_campione where rete='W' and segmento<>'PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente W Private (Non Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='W' and segmento='PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente W Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='W' and segmento='PRIVATE' and Diagnosi='SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente S Retail (Non Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='S' and segmento<>'PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente S Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='S' and segmento<>'PRIVATE' and Diagnosi='SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente S Private (Non Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='S' and segmento='PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente F Retail (Non Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento<>'PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente F Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento<>'PRIVATE' and Diagnosi='SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente F Private (Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento='PRIVATE' and Diagnosi<>'SI' and Professionale='SI' union all select top(1) rete,codice_fiscale,'Cliente F Private (Non Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento='PRIVATE' and Diagnosi<>'SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente F Retail (Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento<>'PRIVATE' and Diagnosi<>'SI' and Professionale='SI' union all select top(1) rete,codice_fiscale,'Cliente F Retail (Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento<>'PRIVATE' and Diagnosi='SI' and Professionale='SI' union all select top(1) rete,codice_fiscale,'Cliente F Private (Non Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='F' and segmento='PRIVATE' and Diagnosi='SI' and Professionale<>'SI' union all select top(1) rete,codice_fiscale,'Cliente S Retail (Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='S' and segmento<>'PRIVATE' and Diagnosi<>'SI' and Professionale='SI' union all select top(1) rete,codice_fiscale,'Cliente S Private (Professionale) con solo Monitoraggio'as Nota from c6martperiodico.rp_tb_tipologia_campione where rete='S' and segmento='PRIVATE' and Diagnosi<>'SI' and Professionale='SI' union all select top(1) rete,codice_fiscale,'Cliente S Private (Non Professionale) con Monitoraggio e Diagnosi'as Nota from c6martperiodico.rp_tb_tipologia_campione w