Untitled
unknown
sql
2 years ago
1.6 kB
7
Indexable
----clientes-- select count( distinct id_cliente_persona ) from `rs-nprd-dlk-dd-az-d8bc.anl_persona.cliente_persona` cp where cp.periodo between '2023-01-01' and '2023-07-01' group by cp.periodo; --contratantes select cd.fec_periodo_corte, count( distinct cd.id_persona_origen) from `rs-nprd-dlk-dd-trsv-ede4.trv_calidad_modelo_persona.consentimiento_datos_personales` cd where cd.fec_periodo_corte between '2023-01-01' and '2023-07-01' and cd.ind_positivo='SI' group by cd.fec_periodo_corte; -----reglas with total as(select cd.fec_periodo_corte,cd.id_regla,nom_campo,cd.ind_positivo, If(cd.des_canal_consentimiento like '%/%' , 'MULTICANAL' , cd.des_canal_consentimiento )canal, --case when cd.des_canal_consentimiento like '%/%'then 'MULTICANAL' --ELSE cd.des_canal_consentimiento --END CANAL, cd.des_valor_origen, count( distinct cd.id_persona_origen ) cantidad from `rs-nprd-dlk-dd-trsv-ede4.trv_calidad_modelo_persona.consentimiento_datos_personales` cd where cd.fec_periodo_corte between '2023-01-01' and '2023-07-01' and cd.ind_positivo in ('SI','NO') and cd.nom_campo in ('CONSENTIDATOSPER','INDCONTACTAR') and id_regla in('RLPD105','RPCC105','RLPD103','RCC003') group by cd.des_canal_consentimiento, cd.fec_periodo_corte, cd.id_regla,nom_campo,cd.ind_positivo, If(cd.des_canal_consentimiento like '%/%' , 'MULTICANAL' , cd.des_canal_consentimiento ), cd.des_valor_origen ) select fec_periodo_corte,id_regla,nom_campo,ind_positivo, canal, des_valor_origen,sum(cantidad) from total group by fec_periodo_corte,id_regla,nom_campo,ind_positivo, canal, des_valor_origen;
Editor is loading...