Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SUM duplicates in Load Script

Hello,

I have a problem in loading script. I don´t know what is wrong.

In a QVD file with several columns I want to apply SUM function.

let´s say:

Year   Product     PRV     Amount

2014   prdA          A          24720

2014   prdB          A          24720

I do apply SUM function like this:

FINAL_QVD:

load PRV,SUM(Amount) as SAmount from QVD.qvd (qvd)

group by PRV;

Finally, when I create a Table from FINAL_QVD I get this:

PRV     SAmount

A          98880


Instead of:

PRV     SAmount

A          49440

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Diego,

it's going to be difficult to work out what's going on here, but it certainly looks like you have duplicates.

You could try adding count(Amount) to see if this is the case.

I'd suggest that you need to look at the code that's creating your original QVD.

Marcus

View solution in original post

2 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Diego,

it's going to be difficult to work out what's going on here, but it certainly looks like you have duplicates.

You could try adding count(Amount) to see if this is the case.

I'd suggest that you need to look at the code that's creating your original QVD.

Marcus

ramoncova06
Specialist III
Specialist III

the distinct field is product, so either you add it as part of your group or you apply a distinct to your sum

FINAL_QVD:

load distinct PRV,SUM(Amount) as SAmount from QVD.qvd (qvd)

group by PRV;