Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
vireshkolagimat
Creator III
Creator III

Order by clause

Hi,

Why can't  we use the Order by clause with load statment. I know that we can use the order by clause with resident load.

Regards,

Viresh

6 Replies
oknotsen
Master III
Master III

You actually can use the "order by" clause when loading from various sources, including resident.

What is your exact problem?

May you live in interesting times!
hubertdudek
Contributor III
Contributor III

You can. If you have any problems you can use preceding load:

LOAD * ORDER BY ....;

LOAD * ....

Peter_Cammaert
Partner - Champion III
Partner - Champion III

His problem probably is that ORDER BY can only be used on RESIDENT tables, not on external file sources (LOAD FROM).

Viresh, that's how QlikView works. Nothing to be done about that.

You can however use the ORDER BY clause in SQL statements any way you like. That may bring some solace, if you use an RDBMS as external data source.

Best,

Peter

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I'm not really sure, but that may well turn your Preceding Load into a Resident Load of a hidden table.

oknotsen
Master III
Master III

His problem probably is that ORDER BY can only be used on RESIDENT tables, not on external file sources (LOAD FROM).

I guess you mean "only not from files", because I am pretty sure you can also use it with various databases. I probably would not recommend it, but you can.

Anyway,

If the OP wants to sort his data in some sort of a way, wouldn't this be a solution:

TableA:

Load from tableA;

TableB:

noconcatenate

Load * from TableA

order by someField;

drop TableA;

rename table TableB to TableA;

May you live in interesting times!
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Of course you're right (see the second statement in my post). But a SELECT is an entirely different beast than a (QlikView) LOAD statement, and as far as I know LOAD doesn't allow for reading RDBMS tables (yet).

A while ago and in another discussion, I posted this snapshot from the QV desktop help. The text is still badly formatted (for a number of years now) so it doesn't do the ORDER BY clause any justice. But it still applies. See the first and fourth sentences:

Help on Order By thread201352.jpg