473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Access - Count records

7
I have a database with records consisting of phone numbers and date/time called.
I can write a query to tell me how many times each number is has been called but also want to know how many once, twice etc. there are.

ie 12 numbers called 1 time, 6 called 2 times, 17 called 3 times.

Help!
Apr 27 '06 #1
6 28711
CaptainD
135 100+
You did not post what you have done so far but nested SQL statements should work.
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(*) AS NumberOfCalls, TimesCalled
  2. FROM [SELECT testPhone.PhoneNumber, testPhone.dDate, Count(testPhone.PhoneNumber) AS TimesCalled
  3. FROM testPhone
  4. GROUP BY testPhone.PhoneNumber, testPhone.dDate]. AS TempTable Group By TimesCalled;
  5.  
Note: the second Select statement in incased in "[]" marks to represent a table
Apr 27 '06 #2
peterb
7
You did not post what you have done so far but nested SQL statements should work.
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(*) AS NumberOfCalls, TimesCalled
  2. FROM [SELECT testPhone.PhoneNumber, testPhone.dDate, Count(testPhone.PhoneNumber) AS TimesCalled
  3. FROM testPhone
  4. GROUP BY testPhone.PhoneNumber, testPhone.dDate]. AS TempTable Group By TimesCalled;
  5.  
Note: the second Select statement in incased in "[]" marks to represent a table
Thanks for this, it works - almost! The query is

SELECT Count(*) AS NumberOfNumbers, TimesCalled
FROM [SELECT cli, Count(*) AS TimesCalled
FROM 1290
GROUP BY cli]. AS TempTable
GROUP BY TimesCalled;

If all the phone numbers (cli) are different it shows 1 call for 16 numbers.

However if 2 are the same it shows

NumberOfNumbers TimesCalled
14 1
1 2

Any ideas?
Apr 28 '06 #3
CaptainD
135 100+
Isn't that what you asked for?
ie 12 numbers called 1 time, 6 called 2 times, 17 called 3 times.
Apr 28 '06 #4
peterb
7
Yes, but this gives both sets of totals for Times Called and Calls.

Thanks for your help to get me started.

SELECT Count(*) AS NumberOfCallers, TempTable.TimesCalled, Count(*)*[TimesCalled] AS Calls
FROM [SELECT Field10, Count(*) AS TimesCalled
FROM 20060424
GROUP BY Field10]. AS TempTable
GROUP BY TempTable.TimesCalled;

Now I need to add the ability to ignore numbers with certain prefixes held in a table and select for last 1, 2 or 3 etc. days...
Apr 28 '06 #5
CaptainD
135 100+
Correct in your query 14 numbers called once and 1 number called twice.

If you have any questions on filtering records just re-post.

Good Luck
Apr 28 '06 #6
Widge
56
I'm trying to do something similar except using VBA on a form but can't get to grips with Count(*) in VBA. I get a string with my SQL statement and what I am then trying to do is use DoCmd.RunSQL statement

This is popping an error saying that RunSQL is expecting a valid SQL statement. So obviously I'm having a formatting issue.

All I'm trying to do is count the amount of records that a search is coming back with for visual feedback purposes. Here is my gumf:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         CSQL = "SELECT Count(*) As Counted FROM AccountCardRegister, AccountCardComments"
  3.         CSQL = CSQL & " WHERE AccountCardRegister.AccountCard LIKE '*" & Cardnumber & "*'"
  4.         DoCmd.RunSQL CSQL
  5.  
  6.  
I was hoping to popuate a textbox with Counted, the result.

Also tried this without the 'As Counted' in the string and had no joy.

Once again, question-a-rama from me, but any help gratefully received!
Apr 19 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
4
by: Sondra Wilson | last post by:
I have created a sorted query. The total(records) I get in the query is correct. My problem lies with getting that total into my report. I use count to insert the total number of records in my...
1
by: Steve Claflin | last post by:
I have a database with a moderate number of records in several tables (the biggest table at the moment is about 800 records). In development it got moved between 2K and XP repeatedly. Several...
3
by: C. Homey | last post by:
I have an Access 2000 database (42,000+ records) for which I need a count of records by state (AL=320, AK=92, NY=1,932, etc). Obviously, I don't want to (and probably can't...) do the count...
6
by: Marlene | last post by:
Hi All I have the following scenario, where I have found all the duplicates in a table, based on an order number and a part number (item).I might have something like this: Order PODate Rec...
15
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
22
by: Bob and Sharon Hiller | last post by:
I have an ASP page that was done in VBScript It is setup to read an Access database and I need to change it to read a Sql 2005 Database. The code that is used to open the Access Database: Set...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
1
by: chungiemo | last post by:
Hi thought I would do another thread as this one is a bit different from the previous problem I am looking for a solution to the relating problem Comparing 2 access databases with 2 tables,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.