Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Script: Add a total column

Hi,

I am wondering if someone can point me to the right direction here.

Suppose I have Table1 below

Table1:

Col1 Col2

a          1

b          2

c          3

d          4

I would like to have a load script t that load Table1 and create Table2 (which add a total column)

Table2:

Col1 Col2 Total

a          1     10

b          2     10

c          3     10

d          4     10

For reason that I won't get into it, I need to use a load script. Can someone help me out, I am just not sure how to accomplish this in QV. Thank you.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Table1:

load Col1, Col2

from ...somewhere...;

join(Table1)

load sum(Col2)

resident Table1;


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
nagaiank
Specialist III
Specialist III

Try the following script:

Table2:

NoConcatenate

Load *, 10 as Total Resident Table1;

Not applicable
Author

Unfortunately, I need the total column to be dynamic. For example, Table1 can have 100 or 1000 or 10000 rows, and I need to be able to calculate that dynamically.

Sent from Samsung Mobile

Gysbert_Wassenaar

Table1:

load Col1, Col2

from ...somewhere...;

join(Table1)

load sum(Col2)

resident Table1;


talk is cheap, supply exceeds demand
Not applicable
Author

Works great, thank you Gysbert.

A quick question (hope you don't mind), what if I need an accummulative sum column, how would I accomplish that? Thank you..

Gysbert_Wassenaar

Table1:

load Col1, Col2, rangesum(peek('Cumulative',Col2) as Cumulative

from ...somewhere...;


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you.