Added AP calculation for a query