On Mon, 4 Aug 2003 14:52:19 +1000, "Huyeote" <(E-Mail Removed)>
wrote:
>Hi, there, I have a Access table which contains hundreds of thousands of
>call logs. The data fields useful in this case is phone number (area code +
>phone no) and duration. And I have another table which records all billable
>area codes (prefix). I need to summarise total of minutes called to every
>single area code from the call details table. Instead of query one area code
>every time in a simple query, can I query minutes to all prefix ( I have
>more than 500 prefix) in just one go? Any help will be appreciated.
Yes, you can, but since apparently you have the area code embedded in
the phone number instead of as a separate (indexed) field, it will be
very slow and inefficient.
Two ways to try, making guesses at your fieldnames which you'll need
to correct:
1. SELECT BillableCodes.AreaCode, Sum(Calls.Calltime) AS SumOfTime
FROM Calls, BillableCodes
WHERE Calls.Phone LIKE BillableCodes.Code & "*"
GROUP BY BillableCodes.AreaCode;
2. a Non Equi Join:
SELECT BillableCodes.AreaCode, Sum(Calls.Calltime) AS SumOfTime
FROM Calls INNER JOIN BillableCodes
ON Calls.Phone LIKE BillableCodes.Code & "*"
GROUP BY BillableCodes.AreaCode;
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public