test mixing join and aggregates