-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - API+APP - Posibilidad de crear tramos #254
base: reporting
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- En la imagen 1 se muestra el resumen de los tramos, mientras que en la imagen 2, al ejecutarse, cambia la simbología. En el resultado final (imagen 2) deberían aparecer los tramos especificados en la imagen 1.
- No se puede modificar ni eliminar el rango implementado. Una vez aplicado, sería necesario quitar el campo y volver a añadirlo.
@ronaldchavezjortilles falta revisar la ordenacion |
Ya se han resuelto los casos encontrados. Ya se puede volver a validar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT CASE
WHEN sda_stic_payment_commitments.amount < 12 THEN '< 12'
WHEN sda_stic_payment_commitments.amount >= 12 AND sda_stic_payment_commitments.amount <= 14 THEN ' 12 - 14'
WHEN sda_stic_payment_commitments.amount >= 15 AND sda_stic_payment_commitments.amount <= 17 THEN ' 15 - 17'
WHEN sda_stic_payment_commitments.amount >= 18 THEN '>= 18'
END as `Importe`
FROM sda_stic_payment_commitments
group by CASE
WHEN sda_stic_payment_commitments.amount < 12 THEN '< 12'
WHEN sda_stic_payment_commitments.amount >= 12 AND sda_stic_payment_commitments.amount <= 14 THEN ' 12 - 14'
WHEN sda_stic_payment_commitments.amount >= 15 AND sda_stic_payment_commitments.amount <= 17 THEN ' 15 - 17'
WHEN sda_stic_payment_commitments.amount >= 18 THEN '>= 18'
END
order by CASE
WHEN sda_stic_payment_commitments.amount < 12 THEN 1
WHEN sda_stic_payment_commitments.amount >= 12 AND sda_stic_payment_commitments.amount <= 14 THEN 2
WHEN sda_stic_payment_commitments.amount >= 15 AND sda_stic_payment_commitments.amount <= 17 THEN 3
WHEN sda_stic_payment_commitments.amount >= 18 THEN 4
END **No**
Al ejecutar la SQL el No que se escribe después del último END genera un error de SQL, Error quering database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No permite usar un rango con números negativos, -11:2:5 no deja insertar el -
Los numeros negativos van en rojo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Si creamos un tramo y el campo tiene una agregación pero no hay valores asociados, el tramo debe mostrarse con un valor de 0. Esto debe suceder únicamente si existe una agregación.
La consulta que se está ejecutando actualmente es la siguiente:
SELECT CASE
WHEN sda_contacts.stic_age_c < 2 THEN '< 2'
WHEN sda_contacts.stic_age_c >= 2 AND sda_contacts.stic_age_c <= 3 THEN ' 2 - 3'
WHEN sda_contacts.stic_age_c >= 4 AND sda_contacts.stic_age_c <= 5 THEN ' 4 - 5'
WHEN sda_contacts.stic_age_c >= 6 AND sda_contacts.stic_age_c <= 6 THEN ' 6 - 6'
WHEN sda_contacts.stic_age_c >= 7 AND sda_contacts.stic_age_c <= 7 THEN ' 7 - 7'
WHEN sda_contacts.stic_age_c >= 8 AND sda_contacts.stic_age_c <= 9 THEN ' 8 - 9'
WHEN sda_contacts.stic_age_c >= 10 THEN '>= 10'
END as `Edad`, cast( count( distinct `sda_contacts`.`first_name`) as decimal(32,0) ) as `Nombre`
FROM sda_contacts
where (`sda_contacts`.`stic_age_c` between
2 and 10 )
group by CASE
WHEN sda_contacts.stic_age_c < 2 THEN '< 2'
WHEN sda_contacts.stic_age_c >= 2 AND sda_contacts.stic_age_c <= 3 THEN ' 2 - 3'
WHEN sda_contacts.stic_age_c >= 4 AND sda_contacts.stic_age_c <= 5 THEN ' 4 - 5'
WHEN sda_contacts.stic_age_c >= 6 AND sda_contacts.stic_age_c <= 6 THEN ' 6 - 6'
WHEN sda_contacts.stic_age_c >= 7 AND sda_contacts.stic_age_c <= 7 THEN ' 7 - 7'
WHEN sda_contacts.stic_age_c >= 8 AND sda_contacts.stic_age_c <= 9 THEN ' 8 - 9'
WHEN sda_contacts.stic_age_c >= 10 THEN '>= 10'
END
Nuevo
Para solucionar el problema y asegurarnos de que se muestren todos los tramos con un valor de 0 si no hay datos, realizamos el siguiente cambio:
WITH ranges AS (
SELECT ' < 2' as `range`
UNION SELECT ' 2 - 3'
UNION SELECT ' 4 - 5'
UNION SELECT ' 6 - 6'
UNION SELECT ' 7 - 7'
UNION SELECT ' 8 - 9'
UNION SELECT '>= 10'
)
SELECT
r.range as 'Edad',
COALESCE(t.Nombre, 0) as 'Nombre'
FROM ranges r
LEFT JOIN (
SELECT
CASE
WHEN stic_age_c < 2 THEN '< 2'
WHEN stic_age_c >= 2 AND stic_age_c <= 3 THEN ' 2 - 3'
WHEN stic_age_c >= 4 AND stic_age_c <= 5 THEN ' 4 - 5'
WHEN stic_age_c >= 6 AND stic_age_c <= 6 THEN ' 6 - 6'
WHEN stic_age_c >= 7 AND stic_age_c <= 7 THEN ' 7 - 7'
WHEN stic_age_c >= 8 AND stic_age_c <= 9 THEN ' 8 - 9'
WHEN stic_age_c >= 10 THEN '>= 10'
END as Edad,
cast(count(distinct first_name) as decimal(32,0)) as Nombre
FROM sda_contacts
WHERE stic_age_c BETWEEN 2 AND 10
GROUP BY
CASE
WHEN stic_age_c < 2 THEN '< 2'
WHEN stic_age_c >= 2 AND stic_age_c <= 3 THEN ' 2 - 3'
WHEN stic_age_c >= 4 AND stic_age_c <= 5 THEN ' 4 - 5'
WHEN stic_age_c >= 6 AND stic_age_c <= 6 THEN ' 6 - 6'
WHEN stic_age_c >= 7 AND stic_age_c <= 7 THEN ' 7 - 7'
WHEN stic_age_c >= 8 AND stic_age_c <= 9 THEN ' 8 - 9'
WHEN stic_age_c >= 10 THEN '>= 10'
END
) t ON r.range = t.Edad
ORDER BY
CASE
WHEN r.range = '< 2' THEN 1
WHEN r.range = ' 2 - 3' THEN 2
WHEN r.range = ' 4 - 5' THEN 3
WHEN r.range = ' 6 - 6' THEN 4
WHEN r.range = ' 7 - 7' THEN 5
WHEN r.range = ' 8 - 9' THEN 6
WHEN r.range = '>= 10' THEN 7
END;
Esta consulta utiliza un WITH para definir los rangos de forma explícita y realiza un LEFT JOIN con la tabla de datos reales, asegurando que los tramos sin datos se muestren con un valor de 0.
El resultado es:
Para las pruebas, se ha utilizado el campo Edad (sin agregación) con un filtro entre 2 y 10, junto con el campo Nombre.
…un valor numérico
Descripción del Cambio
Se añade la posibilidad poder definir rangos de valores sobre un campo numérico. El campo se convierte en un campo de texto. Los rangos se pueden editar.
Issue(s) resuelto(s)
Pruebas a realizar para validar el cambio
Realizar un panel con un campo numérico y definir rangos.