Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4
Description
Returns the last element of the specified column for each element of the given parent table. An order by
expression can be set to define the order that should be used to determine the last element.
PU_LAST can be applied on any data type. The data type of the result is the same as the input column data type.
If no value in the child table exists for the element in the parent table (either because all values of the child table column are filtered out, or because no corresponding value exists in the first place), NULL will be returned.
Syntax
PU_LAST ( parent_table, child_table.column [, filter_expression] [, order_by_expression] )
Examples
Return the case ID of the largest case table value for each company code:
Column1
"companyDetail"."companyCode"
Column2
PU_LAST("companyDetail", "caseTable"."caseId", order by "caseTable"."value")
Return the eventtime of the last activity for each case:
Column1
"companyDetail"."caseId"
Column2
PU_LAST("companyDetail", "activityTable"."eventtime")
activityTable
caseId : INT | activity : STRING | eventtime : DATE |
---|---|---|
1 | 'A' | Fri Jan 01 2016 00:00:00.000 |
1 | 'B' | Tue Feb 02 2016 14:00:00.000 |
1 | 'C' | Sat Apr 02 2016 15:00:00.000 |
1 | 'D' | Sat Apr 02 2016 16:00:00.000 |
2 | 'A' | Fri Jan 01 2016 12:30:00.000 |
2 | 'B' | Fri Jan 01 2016 13:00:00.000 |
2 | 'C' | Fri Jan 01 2016 15:00:00.000 |
2 | 'D' | Fri Jan 01 2016 17:00:00.000 |
companyDetail
Foreign Keys
companyDetail.caseId | activityTable.caseId |
Return the eventtime of the last activity that contains a 'B' for each case:
Column1
"companyDetail"."caseId"
Column2
PU_LAST("companyDetail", "activityTable"."eventtime", "activityTable"."activity" LIKE 'B')
activityTable
caseId : INT | activity : STRING | eventtime : DATE |
---|---|---|
1 | 'A' | Fri Jan 01 2016 00:00:00.000 |
1 | 'B' | Tue Feb 02 2016 14:00:00.000 |
1 | 'C' | Sat Apr 02 2016 15:00:00.000 |
1 | 'D' | Sat Apr 02 2016 16:00:00.000 |
2 | 'A' | Fri Jan 01 2016 12:30:00.000 |
2 | 'B' | Fri Jan 01 2016 13:00:00.000 |
2 | 'C' | Fri Jan 01 2016 15:00:00.000 |
2 | 'D' | Fri Jan 01 2016 17:00:00.000 |
companyDetail
Foreign Keys
companyDetail.caseId | activityTable.caseId |
Return the eventtime of the last activity that contains a 'X' for each case. As there exists no such activity, all activity table values are filtered out, which means that in both cases NULL is returned.
Column1
"companyDetail"."caseId"
Column2
PU_LAST("companyDetail", "activityTable"."eventtime", "activityTable"."activity" LIKE 'X')
activityTable
caseId : INT | activity : STRING | eventtime : DATE |
---|---|---|
1 | 'A' | Fri Jan 01 2016 00:00:00.000 |
1 | 'B' | Tue Feb 02 2016 14:00:00.000 |
1 | 'C' | Sat Apr 02 2016 15:00:00.000 |
1 | 'D' | Sat Apr 02 2016 16:00:00.000 |
2 | 'A' | Fri Jan 01 2016 12:30:00.000 |
2 | 'B' | Fri Jan 01 2016 13:00:00.000 |
2 | 'C' | Fri Jan 01 2016 15:00:00.000 |
2 | 'D' | Fri Jan 01 2016 17:00:00.000 |
companyDetail
Foreign Keys
companyDetail.caseId | activityTable.caseId |