create FirstBy and LastBy aggregation functions