10. Through the Filters tab, add a filter like WHERE in SQL to the data source.
11. Click Make Aggregated to turn the output into an aggregated output.
Read the warning before clicking OK and then add the required aggregation.
This aggregation field will then be added to the Schema tab.
12. In the Aggregation Calculated Fields area under the Calculated Fields tab, add any required calculated fields on aggregations.
See:Functions, Aggregation functions
13. To keep only the latest event per upsert key, click More > Manage Upserts then select the following:
Keys: A unique key identifying a row in the table.
Deletions: The delete key (events with the value true in their deletion key field will be deleted).