Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Vinod
Creator
Creator

How to SQL Query into QlikView Script

Hi All,

How to Write below SQL Query into QlikView Script in Different ways.

SELECT   DLR_CD, BRC_CD,YEAR_MTH,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_01))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_01)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_01)))

             END),0)   AMT_VAL_01,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_02))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_02)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_02)))

             END),0)   AMT_VAL_02,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_03))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_03)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_03)))

             END),0)   AMT_VAL_03

   FROM  TB_RPT_RCOM202

   WHERE KPI_VALUE IN (40,9)

   AND   YEAR_MTH = '201802'

   and brc_cd='BL02A'

   GROUP BY YEAR_MTH,DLR_CD, BRC_CD;

Thanks.

Vinod

Labels (1)
3 Replies
Brett_Bleess
Former Employee
Former Employee

You should be able to copy/paste that into the QlikView Script Editor and run it after creating a Connect To string to connect to the source DB provided your Connector can handle all of the SQL calls you are making.

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

That should get you on the right track.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
usamabinsadiq
Contributor III
Contributor III

Hi,

you can achieve this by doing following :

TB_RPT_RCOM202:
SQL SELECT   DLR_CD, BRC_CD,YEAR_MTH,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_01))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_01)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_01)))

             END),0)   AMT_VAL_01,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_02))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_02)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_02)))

             END),0)   AMT_VAL_02,

            NVL((CASE WHEN (SUM(DECODE(KPI_VALUE,40,AMT_VAL_03))) = 0 THEN 0

             ELSE

                (SUM(DECODE(KPI_VALUE,9,AMT_VAL_03)) ) /

                (SUM(DECODE(KPI_VALUE,40,AMT_VAL_03)))

             END),0)   AMT_VAL_03

   FROM  TB_RPT_RCOM202

   WHERE KPI_VALUE IN (40,9)

   AND   YEAR_MTH = '201802'

   and brc_cd='BL02A'

   GROUP BY YEAR_MTH,DLR_CD, BRC_CD;

I hope this helps.

 

Regards,

if my replay helped you then please press like button and do not forget to press the "Accept as Solution" button.
usamabinsadiq
Contributor III
Contributor III

if my replay helped you then please do not forget to use the "Accept as Solution" button.

if my replay helped you then please press like button and do not forget to press the "Accept as Solution" button.