Queries for data preparation and basic metrics