I am trying to build a query that returns the top ten costs for separate billing cycles. I have tried two approaches: one discussed on this forum and in the MS Knowledge base, and another I got from another Access site. I can't get either to work. Does anyone know why:
Approach 1:
SELECT a.TotCost, a.BillingDate, a.PhoneID
FROM tblSprint AS a
WHERE (((a.TotCost) In (Select Top 10 TotCost from [tblSprint] where [BillingDate]=a.[BillingDate] and [PhoneID]=a.[PhoneID] Order By [BillingDate] desc)));
Approach 2:
FROM qrySprintMonthly AS a
WHERE (((a.BillingDate)>#1/1/2001#) AND (((Select Count(*) from qrySprintMonthly where BillingDate = a.BillingDate and PhoneId = a.PhoneID and AssignedTo = a.AssignedTo)) Between 1 And 10))
ORDER BY a.BillingDate DESC;
They both return all the records.
Thanks,
Neal
Approach 1:
SELECT a.TotCost, a.BillingDate, a.PhoneID
FROM tblSprint AS a
WHERE (((a.TotCost) In (Select Top 10 TotCost from [tblSprint] where [BillingDate]=a.[BillingDate] and [PhoneID]=a.[PhoneID] Order By [BillingDate] desc)));
Approach 2:
FROM qrySprintMonthly AS a
WHERE (((a.BillingDate)>#1/1/2001#) AND (((Select Count(*) from qrySprintMonthly where BillingDate = a.BillingDate and PhoneId = a.PhoneID and AssignedTo = a.AssignedTo)) Between 1 And 10))
ORDER BY a.BillingDate DESC;
They both return all the records.
Thanks,
Neal