Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load

Hello,

In the script i have next:

StartSite:

SELECT * FROM TARGETTABLE;

---------------

In the script i want a new select statement that selects all results from Startsite with e.g. group by

GroupStartSite:

SELECT ColumnA, count(*) FROM <<StartSite>> GROUP BY ColumnA

How do i define a new select statement based on source earlier select statement in script?

Thx in advance

15 Replies
Digvijay_Singh

You need to use resident StartSite instead of FROM, it will do the needful, also we use load instead  of SELECT while loading from QV tables.

swuehl
MVP
MVP

Try

GroupStartSite:

LOAD ColumnA, count(ColumnA) as Count

RESIDENT StartSite

GROUP BY ColumnA;

pokassov
Specialist
Specialist

Hi!

load

     ColumnA,

     count(ColumnA)               As Cnt

Resident StartSite

group by ColumnA;

sasiparupudi1
Master III
Master III

StartSite:

SELECT * FROM TARGETTABLE;

//load the count using a resident load and do not concatenate the result to the main table(if it is your requirement)

final:

noconcatenate load

     Column1,

     count(Column1)               As Column1Count

Resident StartSite

group by Column1;

//finally drop the main table(if it is your requirement)

drop table StartSite;

hth

Sasi

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

You don't really have to extract from database again. Since you've loaded the data into QlikView you have all the fields (*) in StartSite table and what you can do is extract fields that you want from StartSite table.

Use RESIDENT function

As suggested be

GroupStartSite:

LOAD ColumnA, count(ColumnA) as Count

RESIDENT StartSite

GROUP BY ColumnA;

johnca
Specialist
Specialist

Andreas, I have issue with your initial statement. When performing an aggregation in script I think it is bad practice to do a "Select *" (select everything). How would you know what fields to group by? Every field not aggregated is required to be in the Group By statement so you need to know all the field names in the table/view.

V/r,

John

Not applicable
Author

Hi John,

while I agree you might not want to do a load * from the underlying DB.


"Every field not aggregated is required to be in the Group By statement"

This isn't quite right in the QV group by, you don't put in all the fields, just those you want to aggregate by.

hope that helps

Joe

johnca
Specialist
Specialist

Joe, thanks for agreeing with part of it anyway.

I stand corrected.

Not applicable
Author

no worries glad to help