Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlik View Load SQL Select Question

Hi,

Look at below two script:

Load A, B;

SQL Select field1 as A, filed as B from Table;

The result is cannot find the filed A;

But another one is

Load *;

SQL Select field1 as A, filed as B from Table;

This works, I am a bit confused why???

1 Solution

Accepted Solutions
marcus_sommer

I think the reason is quite similar to the topic from these posting: Re: SQL alias for tables in QlikView. It will be a question of the order how qlikview performed the various handles which belonged to a preceeding load and it seems that at this time the field A didn't yet exists.

I think in this sense it's best practice not to make any transformations within the sql-part and perform all transformations within the load-parts, not only because qlikview-functions couldn't be executed from the database but also to don't mixup transformations from a maintainability point of view.

- Marcus

View solution in original post

10 Replies
oknotsen
Master III
Master III

Don't bother about the "why". Don't rename things in your SQL to begin with . Do them in your preceding load.

May you live in interesting times!
nikhilgarg
Specialist II
Specialist II

Hey,

Do like:

Load field1 as A, field 2 as B;

SQL Select field1 , field2  from Table;

Your following script works bcoz you ahve written Load * and it is loading field1 and field2 in the final table .

Load *;

SQL Select field1 as A, filed as B from Table;



Peter_Cammaert
Partner - Champion III
Partner - Champion III

The availability of the AS keyword in SQL depends on the RDBMS you are using. To avoid having to check for a particular DB type and adjust your SQL statement accordingly, do as Onno says: rename your fields in the Precending load like in:

LOAD field1 AS A, filed AS B;

SQL SELECT field1, field FROM Table;

marcus_sommer

The reason is the Preceding Load which isn't a two-step loading (load first table and from there load the second one) - it's more a kind of specialized pipe-loading in one step.

edit: for a solution look to the answers above.

- Marcus

flipside
Partner - Specialist II
Partner - Specialist II

I can't speak for the others but in my experience both statements should work. You CAN use AS in the SQL portion, I do all the time and don't have problems. After the Load * version do you definitely get Field A in your data model?

flipside

Not applicable
Author

yes, the sql after load * works, A is available.

Not applicable
Author

Hmm, I know, but in my mind, it should be work like this, first load the SQL part, and after that Load the key word, Load part. In the blog, Preceding Load, it says, The fact that the SELECT statement is evaluated before the Load.

So I am still very very puzzled.

flipside
Partner - Specialist II
Partner - Specialist II

Are these actual scripts or re-written examples to demonstrate the issue? It may help to post the actual script if you can.

marcus_sommer

I think the reason is quite similar to the topic from these posting: Re: SQL alias for tables in QlikView. It will be a question of the order how qlikview performed the various handles which belonged to a preceeding load and it seems that at this time the field A didn't yet exists.

I think in this sense it's best practice not to make any transformations within the sql-part and perform all transformations within the load-parts, not only because qlikview-functions couldn't be executed from the database but also to don't mixup transformations from a maintainability point of view.

- Marcus