Hola amigos,
¿Una pregunta, hay un equivalente en qlikview para solicionar esta consulta?
SELECT CURP
FROM ALUMNOGR a
WHERE (AlGProme < 6 and PEsCve <> 3) OR (PEsCve = 3 and EAGCve NOT IN ('P','C','NP'))
Tengo esto en el SCRIPT y al parecer si funciona. Sin embargo, no me da el resultado correcto.
LOAD
IF(AlGProme < 6 AND PEsCve <> 3 OR PEsCve = 3 AND NOT WildMatch(EAGCve,'P','C','NP'), 1,0) AS FLAG_RIESGO
FROM ALUMNOGR
¿Lo podría resolver en SET ANALYSIS?
Pero me quedo atorado en el tema del "NOT IN"
COUNT({$<AlGProme={'<6'}, PEsCve={"*"}-{'3'}... ¿ OR ? PEsCve = {3}, EAGCve ={"*"}-('P','C','NP')>} CURP)
Si alguien me pudiera orientar se los agradecería, mucho. Saludos.
puedes usar + para hacer un cruce entre diferente data sets in to expresión
COUNT({$<AlGProme={'<6'}, PEsCve={"*"}-{'3'}>
+
<PEsCve = {3}, EAGCve ={"*"}-('P','C','NP')>
} CURP)
aqui esta la explicacion de QV
Arguments:
Operator | Description |
+ | Union. This binary operation returns a set consisting of the records that belong to any of the two set operands. |
- | Exclusion. This binary operation returns a set of the records that belong to the first but not the other of the two set operands. Also, when used as a unary operator, it returns the complement set. |
* | Intersection. This binary operation returns a set consisting of the records that belong to both of the two set operands. |
/ | Symmetric difference (XOR). This binary operation returns a set consisting of the records that belong to either, but not both of the two set operands. |
Hola Raul:
Tabla:
LOAD CURP as FLAGRIESO,
Cantidad;
SELECT CURP, COUNT(*) as Cantidad;
FROM ALUMNOGR a
WHERE (AlGProme < 6 and PEsCve <> 3) OR (PEsCve = 3 and EAGCve NOT IN ('P','C','NP'))
GROUP BY CURP
ORDER BY CURP;
Te cargará la tabla con los valores de CURP que estás buscando y cuantas veces se repite cada uno.
Saludos
Joaquín
Hola JoaquinLR Gracias por la respuesta.
¿A nivel de campo hay alguna solución a este Query? Y también me gustaría saber si lo pueda hacer desde Diseño, utilizando una tabla pivotante o un objeto de texto.
Desde campo estaba pensando esto:
IF(AlGProme < 6 AND PEsCve <> 3 OR PEsCve = 3 AND NOT WildMatch(EAGCve,'P','C','NP'), 1,0) AS FLAG_RIESGO
Desde diseño estaba pensando en algo así:
COUNT({$<AlGProme={'<6'}, PEsCve={"*"}-{'3'}... ¿ OR ? PEsCve = {3}, EAGCve ={"*"}-('P','C','NP')>} CURP)
Lo quiero resolver de alguna de las dos formas (en campo o en diseño) por el hecho que, tengo que hacer varias consultas similares a la tabla original. Sacando al rededor de 7 indicadores. Es la razón por la cual no le he pegado a la tabla con una codición desde Script.
Gracias, amigo.
Hola Raúl:
Te he puesto una instrucción load que te genera el campo CURP como FLAGRIESGO y su cuenta de valores durante la ejecución del script.
Si pones como dimensión FLAGRIESGO y como expresión sum(cantidad) ya tienes lo que supuestamente necesitas.
Intenta simular con el excel lo que quieres mostrar y añade una copia de pantalla, quizá no entiendo bien que resultado esperas obtener ni cuales son los datos de partida.
Saludos
Joaquín
Efectivamente JoaquinLR, lo puedo resolver desde la extraccion mediante condiciones. Sin embargo, no lo puedo realizar así por esta razón.
Por esta razón el Query lo debo resolver a nivel Diseño o en el Campo del QVD pero sin usar un WHERE. Ya que esto me reduciría los datos.
puedes usar + para hacer un cruce entre diferente data sets in to expresión
COUNT({$<AlGProme={'<6'}, PEsCve={"*"}-{'3'}>
+
<PEsCve = {3}, EAGCve ={"*"}-('P','C','NP')>
} CURP)
aqui esta la explicacion de QV
Arguments:
Operator | Description |
+ | Union. This binary operation returns a set consisting of the records that belong to any of the two set operands. |
- | Exclusion. This binary operation returns a set of the records that belong to the first but not the other of the two set operands. Also, when used as a unary operator, it returns the complement set. |
* | Intersection. This binary operation returns a set consisting of the records that belong to both of the two set operands. |
/ | Symmetric difference (XOR). This binary operation returns a set consisting of the records that belong to either, but not both of the two set operands. |
Primero segun veo en el script, debe encerrar dentro del parentesis igual que lo estas haciendo en la expresion en SQL, puesto que el OR evaluara sobre las dos operaciones, como esta solo esta evaluando el sobre la primera que esta ahi. Y sobre la segunda expresion, no veo porque usas un wildmatch cuando tienes un caracter para comprar, solo debes usar Match.
Lo segundo, tambien se puede hacer a traves de un set analysis, debes usar P() o E() dependiendo del caso, revisa el manual para amplies el concepto.
Si es posible publica un pequeno ejemplo de datos y coloca una tabla con cuales deberian ser los resultados esperados.