473,399 Members | 2,159 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,399 software developers and data experts.

Access query Distinct Row Count

I have a query that I want the count to be incremental for each number with the same date

Entry Date Number Count
01/15/2016 30519 1
01/15/2016 30519 2
01/15/2016 30519 3
01/15/2016 30519 4
01/16/2016 12345 1
01/16/2016 12345 2
01/16/2016 12345 3
01/16/2016 12345 4
01/15/2016 34569 1
01/15/2016 34569 2
Jan 20 '16 #1
4 1601
Rabbit
12,516 Expert Mod 8TB
You're going to need another field in there that's distinct by row or by the natural key. It's not possible to do otherwise aside from using VBA to do it row by row which can be extremely slow if you have a large dataset.
Jan 21 '16 #2
mbizup
80 64KB
You probably already have a primary key field in your table, since Access practically begs you to include one when you create a table. If that PK field is autonumbering, you can use it to definitively determine the order of the records. Alternatively, if your Entry Date field includes a time stamp, then that field could be used for the same purpose. The timestamp could be split into a date part for grouping while using the time part to determine order. Basically, you need to have some way to determine the order of records where the Number and Entry Date fields are the same.

If you can do that, then your record number can be determined by a SELECT COUNT(X) subquery using criteria that includes records where the PK (or Time Stamp) field is LESS than that in the current record, and the Number field and Date are equal to that in the current record.
Jan 21 '16 #3
I have added an id# that is autonumber.

Entry Date Number ID# Count
1/15/2016 30519 1 1
1/15/2016 30519 2 2
1/15/2016 30519 3 3
1/15/2016 30519 4 4
1/16/2016 12345 5 1
1/16/2016 12345 7 2
1/16/2016 12345 8 3
1/16/2016 12345 9 4
1/15/2016 34569 5 1
1/15/2016 34569 6 2
Jan 21 '16 #4
Rabbit
12,516 Expert Mod 8TB
You can use a ranking query to accomplish what you want.
https://bytes.com/topic/access/insig...-ms-access-sql
Jan 21 '16 #5

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

Similar topics

5
by: anthonyberet | last post by:
I work for an organisation that uses a bespoke document imaging system, the database of which is an MS sql server. We have MS Access and already use it for some querying of the database. The...
2
by: Anne Heddal | last post by:
In the first line I'm trying to count the the unqiue values of the ID column, but I'm getting syntax error, any idea how to format the distinct count? SELECT Count(test.ID) AS IDCOUNT FROM...
1
by: Alex | last post by:
Hi all, In Microsoft Access 2000, how do I tell a query to count a null as zero? I'm adding several columns of data, and many contain nulls, but that makes my results be null as well. Is there...
7
by: Rob Richardson | last post by:
Greetings! I am rewriting a VB6 application in VB .Net. The database (which was converted from Access 97 into Access 2000) has two nearly identical queries. One, called GetNewOrderNumber, is: ...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
1
by: Bill | last post by:
I'm trying to write a query that will select a distinct count of more than one field. I have records that display user productivity. Each of the records have a time associated with it and I want to...
7
by: narpet | last post by:
Okay... here's another query that I need to write that I just can't seem to figure out. first the table layout (table name TEST): ID# PreID# PostID# Dollars 1 2 1...
1
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our...
7
by: AccessHunter | last post by:
Hi, Please help with this problem. I have a report that displays a list of Case/Judge Records. using the following fields, Case Nbr, Case Seq Nbr, Judge Name, Attorney name 723187, 1...
1
by: KMEscherich | last post by:
Using Access 2003 Hi there, am wondering if someone can please help me with retrieving DISTINCT COUNT of a type field. I can get a total, which in this example would = 9, but I also need to know...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.