Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ranibosch
Creator
Creator

Versions of document numbers

Good day,

I've got a list of sales order archives with a number of versions.

How do I write my script to only look at the latest version of each sales order?

Each sales order does not have the same number of versions.

See attached test data.

1 Solution

Accepted Solutions
nedcliqs
Contributor III
Contributor III

Hi  Rani

Please try this code

SalesTB: 

LOAD * INLINE [ 

    SOnumber, VersionNumber, Amount, Date

    SO44,1,40,41607

    SO46,1,50,41722

    SO99,1,30,41798

    SO44,4,80,34677

    SO99,3,70,45368

    SO77,1,50,34748

    SO77,6,400,65799

]; 

 

LatestVersion: 

inner keep load 

    SOnumber, 

    max(VersionNumber) as VersionNumber

resident SalesTB 

group by SOnumber; 

drop table LatestVersion;

xpectedOUT.JPG

TheOutput

the output.JPG

cleveranjos‌ , i got this idea from your post, thanks

View solution in original post

2 Replies
nedcliqs
Contributor III
Contributor III

Hi  Rani

Please try this code

SalesTB: 

LOAD * INLINE [ 

    SOnumber, VersionNumber, Amount, Date

    SO44,1,40,41607

    SO46,1,50,41722

    SO99,1,30,41798

    SO44,4,80,34677

    SO99,3,70,45368

    SO77,1,50,34748

    SO77,6,400,65799

]; 

 

LatestVersion: 

inner keep load 

    SOnumber, 

    max(VersionNumber) as VersionNumber

resident SalesTB 

group by SOnumber; 

drop table LatestVersion;

xpectedOUT.JPG

TheOutput

the output.JPG

cleveranjos‌ , i got this idea from your post, thanks

Clever_Anjos
Employee
Employee

Good to read that, keep in touch!