Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
mfcelleri
Contributor II
Contributor II

Complex SQL Select

Hi guys;

Is there any way to store in a qvd file; a complex SQL Statement like this? How can I do?

SQL SELECT saeprbo.prbo_cod_prod,
saeprbo.prbo_cod_bode,
saeprbo.prbo_cod_unid,
saeprbo.prbo_cod_empr,
saeprbo.prbo_cod_sucu,
(select sum(case d.defi_tip_defi when '5' then c.dmov_can_dmov when '0' then c.dmov_can_dmov when '1' then - c.dmov_can_dmov when '6' then -c.dmov_can_dmov end)
from saedmov c,saeminv b,saedefi d
where b.minv_cod_empr= c.dmov_cod_empr and
b.minv_cod_sucu= c.dmov_cod_sucu and
b.minv_num_comp= c.dmov_num_comp and
c.dmov_cod_prod= saeprbo.prbo_cod_prod and
d.defi_cod_empr = b.minv_cod_empr and
d.defi_cod_tran = b.minv_cod_tran and
b.minv_fmov <= today ) ingresos,
(select sum(case d.defi_tip_defi when '5' then c.dmov_can_dmov when '0' then c.dmov_can_dmov when '1' then - c.dmov_can_dmov when '6' then c.dmov_can_dmov end)
from saedmov c,saeminv b,saedefi d
where b.minv_cod_empr= c.dmov_cod_empr and
b.minv_cod_sucu= c.dmov_cod_sucu and
b.minv_num_comp= c.dmov_num_comp and
c.dmov_cod_prod= saeprbo.prbo_cod_prod and
d.defi_cod_empr = b.minv_cod_empr and
d.defi_cod_tran = b.minv_cod_tran and
b.minv_cod_empr = saeprbo.prbo_cod_empr and
(c.dmov_bod_envi = saeprbo.prbo_cod_bode) and
b.minv_fmov <= today ) egresos
FROM saeprbo,
saeprod a
WHERE ( a.prod_cod_prod = saeprbo.prbo_cod_prod ) and
( a.prod_cod_empr = saeprbo.prbo_cod_empr ) and
( a.prod_cod_sucu = saeprbo.prbo_cod_sucu );

Labels (1)
3 Replies
dplr-rn
Partner - Master III
Partner - Master III

Not clear what your need is. You want to save the sql (text) into a qvd? Or the output into a qvd?
Please elaborate your use case, why etc.
mfcelleri
Contributor II
Contributor II
Author

I need to run this sql code, an save the result in a qvd file.

dplr-rn
Partner - Master III
Partner - Master III

OK.

in your load script do below

. replace your-sql with the actual one

mytable:
load *
;
sql
your-sql
;

Store mytable into 'lib://FolderConnection/mytable.qvd';

 

refer

https://help.qlik.com/en-US/sense/June2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularS...