I have an ordertable with original orders (-00) and subesequent suborders that are derived from the original order (-XX). Something like this:
Now I want to render a table with only the max/last order suffix, in fact I don't want to load the lower numbered orders, rendering a table that would look like:
How can I achieve this ?
Solved! Go to Solution.
split the field into two fields, and then use max and group by to get your result
max(orderid) as maxorderID
subfield(yourfield, '-', 1) as order,
subfield(yourfield, '-', 2) as orderID
this is what you need:
LOAD * Inline [
LOAD Left(myField,5) as Order, Right(myField,2) as SubOrder Resident MyTable;
Left Join (Temp)
LOAD Order, Max(SubOrder) as SubOrder, 'isMax' as flag Resident Temp Group By Order;
if you always have the last two digits to consider, you can split those into a new field and then use the aggregation function max() on those.
Just keep in mind that you need a GROUP BY clause to encompass all othr fields that you have in your table.
I am using the code you presented, but I don't get the wanted result.
The resulting table still doesn't only contain the last suborder in the order series, but contain all orders.
How do I go about excluding the unwanted results in the final table?