Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Applies to:  

Status
colourGreen
titleCelonis 4.0
 
Status
colourGreen
titleCelonis 4.2
 
Status
colourGreen
titleCelonis 4.3
 
Status
colourGreen
titleCelonis 4.4
 

Description

Returns the first 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 first element.

PU_FIRST 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


Code Block
languagetext
themeDJango
PU_FIRST ( parent_table, child_table.column [, filter_expression] [, order_by_expression] )


Examples

Return the case ID of the smallest case table value for each company code:


Panel
titleQuery
Column1


Code Block
languagetext
themeDJango
"companyDetail"."companyCode"


Column2


Code Block
languagetext
themeDJango
PU_FIRST("companyDetail", "caseTable"."caseId", order by "caseTable"."value")




Panel
titleInput
caseTable


caseId : INTcompanyCode : STRINGvalue : INT
1
'001'
600
2
'001'
400
3
'001'
200
4
'002'
300
5
'002'
300
6
'003'
200


companyDetail


companyCode : STRINGcountry : STRING
'001''DE'
'002''DE'
'003''US'



Foreign Keys


caseTable.companyCodecompanyDetail.companyCode




Panel
titleOutput
Result


Column1 : STRINGColumn2 : INT
'001'
3
'002'
4
'003'
6






Return the eventtime of the first activity for each case:


Panel
titleQuery
Column1


Code Block
languagetext
themeDJango
"companyDetail"."caseId"


Column2


Code Block
languagetext
themeDJango
PU_FIRST("companyDetail", "activityTable"."eventtime")




Panel
titleInput
activityTable


caseId : INTactivity : STRINGeventtime : 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


caseId : INTcountry : STRING
1
'DE'
2
'DE'



Foreign Keys


companyDetail.caseIdactivityTable.caseId




Panel
titleOutput
Result


Column1 : INTColumn2 : DATE
1
Fri Jan 01 2016 00:00:00.000
2
Fri Jan 01 2016 12:30:00.000






Return the eventtime of the first activity that contains a 'B' for each case:


Panel
titleQuery
Column1


Code Block
languagetext
themeDJango
"companyDetail"."caseId"


Column2


Code Block
languagetext
themeDJango
PU_FIRST("companyDetail", "activityTable"."eventtime", "activityTable"."activity" LIKE 'B')




Panel
titleInput
activityTable


caseId : INTactivity : STRINGeventtime : 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


caseId : INTcountry : STRING
1
'DE'
2
'DE'



Foreign Keys


companyDetail.caseIdactivityTable.caseId




Panel
titleOutput
Result


Column1 : INTColumn2 : DATE
1
Tue Feb 02 2016 14:00:00.000
2
Fri Jan 01 2016 13:00:00.000






Return the eventtime of the first 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.


Panel
titleQuery
Column1


Code Block
languagetext
themeDJango
"companyDetail"."caseId"


Column2


Code Block
languagetext
themeDJango
PU_FIRST("companyDetail", "activityTable"."eventtime", "activityTable"."activity" LIKE 'X')




Panel
titleInput
activityTable


caseId : INTactivity : STRINGeventtime : 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


caseId : INTcountry : STRING
1
'DE'
2
'DE'



Foreign Keys


companyDetail.caseIdactivityTable.caseId




Panel
titleOutput
Result


Column1 : INTColumn2 : DATE
1
null
2
null