Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
Hope for your help with a general task.
I have the Table_1:
Client Quantity Price
Sara 2 20 Eiro
Sara 4 15 Eiro
Sara 6 10 Eiro
I need to create additional table with intervals, like Table_2:
Client QuantityFrom QuantityTo Price
Sara 0 3.999 20
Sara 4 5.999 15
Sara 6 10000 10
Thank you in advance!
P.S.: it is a subtask for my general goal
Hi,
Try this solution
tmp:
LOAD * INLINE [
Client, Quantity , Price
Sara , 2 , 20 Eiro
Sara, 4 , 15 Eiro
Sara , 6 , 10 Eiro
];
NOCONCATENATE
tmp1:
LOAD
*,
IF(PREVIOUS(Quantity) > Quantity AND PREVIOUS(Quantity) <> Quantity OR ROWNO() =1,
NUM(Quantity - 0.01)) AS [NewField]
RESIDENT tmp
ORDER BY Price ASC
;
DROP TABLE tmp;
The first row in the input table had a quantity of 2, why is the output beginning with 0 instead of 2? Also, the last row of output goes up to 10,000? Does it always stay at 10,000 or can this vary?
My goal is to define the correct price for a client. The minimal price which he can get is 10 Eiro in case, when he puchae more (or equal) than 6 KG of a product.
In our case he will never get more than 10 000 (or 100 000) Kg of the product
Hi,
Try this solution
tmp:
LOAD * INLINE [
Client, Quantity , Price
Sara , 2 , 20 Eiro
Sara, 4 , 15 Eiro
Sara , 6 , 10 Eiro
];
NOCONCATENATE
tmp1:
LOAD
*,
IF(PREVIOUS(Quantity) > Quantity AND PREVIOUS(Quantity) <> Quantity OR ROWNO() =1,
NUM(Quantity - 0.01)) AS [NewField]
RESIDENT tmp
ORDER BY Price ASC
;
DROP TABLE tmp;