Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
9917mark
Contributor III
Contributor III

Allocate a sequence number from 1 to 7

Evening,

I have  a requirement to allocate a sequence number to my data from 1 to 7.

This must then repeat from 1 to 7 until the table has finished loading.

Table consists of a list of SKU's totaling 87000 

The Idea is to use the sequence number to filter the data for easier analysis.

And then export each sequence number to an excel spreadsheet for import.

Sample Raw Data:

sku
1000000
1000001
1000003
1000004
1000005
1000006
1000007
1000008
1000009
1000010
1000011
1000012
1000014
1000015
1000016

 

Desired Result:

sku Seq
1000000 1
1000001 2
1000003 3
1000004 4
1000005 5
1000006 6
1000007 7
1000008 1
1000009 2
1000010 3
1000011 4
1000012 5
1000014 6
1000015 7
1000016 1

 

Thank you in advance.

Labels (1)
2 Replies
QFabian
Specialist III
Specialist III

Hi @9917mark , here an example, please check if works for you :

Aux:
LOAD * INLINE [
sku
1000000
1000001
1000003
1000004
1000005
1000006
1000007
1000008
1000009
1000010
1000011
1000012
1000014
1000015
1000016
];

SKU:
Load
rowno() as Idf,
sku,
if(rowno() = 1 or peek(Seven) = 7, 1, peek(Seven) + 1) as Seven
Resident Aux;
drop table Aux,

OUTPUT :

QFabian_0-1648581491012.png

 

QFabian