问题
How it would be this query in Qlik Sense syntax in data loader script?
TABLA_UTIL:
SQL
SELECT "PERIODO", SUM(DEUDAFINAL) as "DEUDAFINAL"
FROM "DL_RG_ANALYTICS"."SH_PROVISION" PRO WHERE ORG='628'
GROUP BY PERIODO
concatenate
SQL
SELECT OL.PERIODO, SUM(ABIERTA/1000000)+ DEUDA/1000000
FROM "DL_RG_ANALYTICS"."SH_OTRAS_LINEAS" OL LEFT JOIN SH_SALDO_NO_IDEN_RUT PRO ON(OL.PERIODO=PRO.PERIODO)
WHERE ((ol.TIPO_DEUDA='TRASPASO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='SAE' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='REPACTACIONES' AND ol.DEFINICION='SALDO')
OR (ol.TIPO_DEUDA='RENEGOCIADO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='AVANCE_EFECTIVO' AND ol.DEFINICION='SALDO' ))
AND PRO.TipoTarjeta='ABIERTA'
GROUP BY OL.PERIODO, PRO.DEUDA
Any help is welcome, thanks.
回答1:
Hy,
that's easy, so cheer up. If all field names in each table are identical, Qlik Sense will set this to one immediately after the other. To make it unambiguous:
concatenate(table_name)
is a good idea.
Look at this:
- qlik script guide concatenate
Here's your example:
LIB CONNECT TO 'your_database';
TABLA_UTIL:
Load *;
SQL
SELECT
"PERIODO",
SUM(DEUDAFINAL) as "DEUDAFINAL"
FROM
"DL_RG_ANALYTICS"."SH_PROVISION" PRO WHERE ORG='628'
GROUP BY PERIODO;
LIB CONNECT TO 'your_second_database'; // where necessary
concatenate(TABLA_UTIL) //all field names must be the same
Load *;
SQL
SELECT
OL.PERIODO as "PERIODO",
SUM(ABIERTA/1000000)+ DEUDA/1000000 as "DEUDAFINAL"
FROM
"DL_RG_ANALYTICS"."SH_OTRAS_LINEAS" OL LEFT JOIN SH_SALDO_NO_IDEN_RUT PRO ON(OL.PERIODO=PRO.PERIODO)
WHERE ((ol.TIPO_DEUDA='TRASPASO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='SAE' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='REPACTACIONES' AND ol.DEFINICION='SALDO')
OR (ol.TIPO_DEUDA='RENEGOCIADO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='AVANCE_EFECTIVO' AND ol.DEFINICION='SALDO' ))
AND PRO.TipoTarjeta='ABIERTA'
GROUP BY OL.PERIODO, PRO.DEUDA;
//done
来源:https://stackoverflow.com/questions/60748086/qlik-sense-syntax-in-data-loader-script