The outlet extract is ready for an analytical notebook. Its manager wants both detail rows and summary measures, so decide whether each task needs a window or a grouped result. A window keeps order grain. groupBy changes the grain to the requested keys.
You will revisit transformations from this unit on a separate extract. No new operation is required. Keep buyer identifiers distinct from order identifiers, and use a named tie-breaker for a latest-row result. An average should not silently treat unknown amounts as zero. For the joined output, customers with no orders and orders with no customer are different populations. The requested direction of a join determines which one you retain. Inspect the selected columns before you check the answer.