Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
NEED TO CREATE AN ACCOUNTANT IN USING Rowno SCRIP (), COUNT TO RESTART THE NEXT DAY FOLLOWING THE EXAMPLE.
DAY SALES COUNTER
1 100 1
1 200 2
1 400 3
2 800 1
2 800 2
3 400 1
3 500 2
THANKS
Hi, try this code:
sales_temp:
LOAD * Inline [
DAY, SALES
1, 100,
1, 200,
1, 400,
2, 800,
2, 800,
3, 400,
3, 500,
];
// Find the first and last dates
temp_min_max:
LOAD min(DAY) as minDay
,max(DAY) as maxDay
Resident sales_temp;
LET sVar_MinDay = peek('minDay',0,'temp_min_max');
LET sVar_MaxDay = peek('maxDay',0,'temp_min_max');
drop table temp_min_max;
LET sVar_RowMinus = 0;
// Loop through the dates, presume there are no missing dates but I don't think that will cause a problem
for sVar_DayStep = sVar_MinDay to sVar_MaxDay
Sales:
LOAD *
,RowNo()-$(sVar_RowMinus) as Step
Resident sales_temp
where DAY = $(sVar_DayStep);
Let sVar_RowMinus = NoOfRows('Sales');
next sVar_DayStep
drop table sales_temp;