Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
julioarriaga
Contributor II

How do I make the equivalent of QV's Preceding Load in SQL?

I will make some SQL experts cringe with this question, sorry ; I am self-taught and a rookie in QV and SQL.


So, I want to thank everybody in advance for the help.


I learned recently the use of QV's preceding loads. I need to do something similar to a QV's preceding load in a SQL query but I can't get my head around it.


This is the query I'm trying to do (code and image). Basically I'm trying to do the total count of records of a select grouped of records, but it marks me the following error in the Teradata SQL Assistant (image 2):

select count(*)

from (select Producto_ID, count(Producto_ID)

          from DWH.MF_PRODUCTO_ORGANIZACION

          where 1=1

          and EntidadLegal_ID='191'

          and Tipo_Producto_ID='1'

          group by Producto_ID

          having count(Producto_ID)>1

          );


(image 1)

Capture1.PNG

(image 2)

Capture2.PNG

1 Solution

Accepted Solutions

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Sunny may be right. Your SQL engine appears to be complaining about the last ); lacking a name.

Try to name the result set of the inner select (Sunny called it p)

7 Replies
devarasu07
Honored Contributor II

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Hi,

Try to keep only inner select query and remove outer select count(*) part (refer below screen highlighted one in yellow)

Capture.JPG

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Re: How do I make the equivalent of QV's Preceding Load in SQL?

May be this

select count(*)

from (select Producto_ID, count(Producto_ID) Count

          from DWH.MF_PRODUCTO_ORGANIZACION

          where 1=1

          and EntidadLegal_ID='191'

          and Tipo_Producto_ID='1'

          group by Producto_ID

          having count(Producto_ID)>1

          ) p;

Re: How do I make the equivalent of QV's Preceding Load in SQL?

This is a nested SELECT.

If you omit the outer select count(*) from (...), does the inner SELECT work ok on your Teradata DB? Does it produce the expected output?

julioarriaga
Contributor II

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Hi, yes, it does :s

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Did you try to look at the link I provided?

Re: How do I make the equivalent of QV's Preceding Load in SQL?

Sunny may be right. Your SQL engine appears to be complaining about the last ); lacking a name.

Try to name the result set of the inner select (Sunny called it p)

Community Browser