Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add values to sql query

Helo guys,

So I have this SQL query that regurts a set of number (1,2,3,4,5,6....,1999,2000,2001) .

I would like to add to these results 3 more values, for example, if I have 1,2,3,4,5,6....,1999,2000,2001 and I add the values I would get 1,2,3,4,5,6....,1999,2000,2001,2002,2003,2004.

How can I achieve this?

Thank you in advance!!

Best regards.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this sample script

QV_Table:

LOAD

*

INLINE

[

Sequence, Dim

100,abc

101,def

102,ghi ];

MaxValue:

LOAD

Max(Sequence) AS MaxSequence

RESIDENT QV_Table;

LET vMaxSequence = Peek('MaxSequence');

DROP TABLE MaxValue;

Concatenate(QV_Table)

LOAD

  $(vMaxSequence) + RecNo() AS Sequence

Autogenerate(3);

I am getting additional records with 103, 104 and 105.

Regards,

Jagan.

View solution in original post

16 Replies
maleksafa
Specialist
Specialist

based on what you need to add the values, what is the pattern?

Not applicable
Author

This is to be used on a table where I see values in a FIFO system.

The values I get from my query are things that already happened (green), and the values I want to add are things that are going to happen (grey).

If there is a better way to achieve this without messing with the query I wouldn't mind

anbu1984
Master III
Master III

Table:

Load Sequence,Number,Time From Table

Concatenate

Load Max(Sequence)+1 As Sequence Resident Table

Concatenate

Load Max(Sequence)+2 As Sequence Resident Table

Concatenate

Load Max(Sequence)+3 As Sequence Resident Table

Not applicable
Author

Is the "Table" from "Load Sequence,Number,Time From Table"

what I use in the sql query?

anbu1984
Master III
Master III

QV_Table:

Sql Select Sequence,Number,Time From Table;

Concatenate

Load Max(Sequence)+1 As Sequence Resident QV_Table;

Concatenate

Load Max(Sequence)+2 As Sequence Resident QV_Table;

Concatenate

Load Max(Sequence)+3 As Sequence Resident QV_Table;

Not applicable
Author

Nop, I still get an error.

It seems like QV is looking for "Table" on the project's folder...

I don't understand why

Marcio_Campestrini
Specialist
Specialist

Hi Ivo,

Change the "Table" In SQL command by your table name.

Márcio

Márcio Rodrigo Campestrini
Not applicable
Author

I use a lot of tables on my query (and the respective relation between foreign and primary keys).

But even with all those tables I still get the same error. It seems that QV is always looking for something on the folder.

Marcio_Campestrini
Specialist
Specialist

Ivo,

You have to analyze your entire script and identify what (or whom) tables are needed. The example works only if you have all the fields coming from the same table, and the "Table" exist in the database.

If possible, share the qvw file so we can guide you.

Márcio

Márcio Rodrigo Campestrini