45 lines
3.9 KiB
SQL
45 lines
3.9 KiB
SQL
-- Schema: C6MartPeriodico
|
|
-- Stored Procedure: Estrazione_Campione
|
|
|
|
|
|
|
|
|
|
|
|
CREATE procedure [C6MartPeriodico].[Estrazione_Campione]
|
|
AS
|
|
BEGIN
|
|
drop table if exists C6MartPeriodico.TB_Estrazione_Campione
|
|
select top(1) rete_acn,codice_fiscale,'Cliente W Retail (Non Professionale) con solo Monitoraggio' as Nota into C6MartPeriodico.TB_Estrazione_Campione from C6MartPeriodico.tabellone where rete_acn='W' and segmento<>'PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente W Private (Non Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='W' and segmento='PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente W Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='W' and segmento='PRIVATE' and freq_diagnosi='T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Retail (Non Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento<>'PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento<>'PRIVATE' and freq_diagnosi='T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Private (Non Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento='PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Retail (Non Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento<>'PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Retail (Non Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento<>'PRIVATE' and freq_diagnosi='T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Private (Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento='PRIVATE' and freq_diagnosi<>'T' and flgprof='S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Private (Non Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento='PRIVATE' and freq_diagnosi<>'T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Retail (Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento<>'PRIVATE' and freq_diagnosi<>'T' and flgprof='S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Retail (Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento<>'PRIVATE' and freq_diagnosi='T' and flgprof='S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente F Private (Non Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='F' and segmento='PRIVATE' and freq_diagnosi='T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Retail (Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento<>'PRIVATE' and freq_diagnosi<>'T' and flgprof='S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Private (Professionale) con solo Monitoraggio'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento='PRIVATE' and freq_diagnosi<>'T' and flgprof='S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente S Private (Non Professionale) con Monitoraggio e Diagnosi'as Nota from C6MartPeriodico.tabellone where rete_acn='S' and segmento='PRIVATE' and freq_diagnosi='T' and flgprof<>'S'
|
|
union all
|
|
select top(1) rete_acn,codice_fiscale,'Cliente W Retail (Professionale) con solo Monitoraggio' as Not
|