A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Return a count of unique entries?



 
 
Thread Tools Display Modes
  #1  
Old February 3rd, 2005, 01:46 PM
Tony
external usenet poster
 
Posts: n/a
Default Return a count of unique entries?

I am hoping someone can help me here.
I am trying to return a unique count of Applications no's
by Department from a union query containing 10000+
records.
Overall, there are 30 Departments and 1900 Applications
No's in my DB. Applications No's are always allocated to
one Department only.
I want to return a list of Departments that shows an
unique count of Applications No's

For example...

Dept ApplicationNo
A 122
A 122
A 234
B 345
B 345

This would work out to be..

Dept CountofApplicationNo
A 2
B 1

Can this be done?

Thanks

Tony

  #2  
Old February 3rd, 2005, 04:39 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

Brian Camire wrote:

You might try something like this:

SELECT
Dept,
Count(*) AS CountofApplicationNo
FROM
(SELECT DISTINCT
Dept,
ApplicationNo
FROM
YourTable)
GROUP BY
Dept

Access 97 and earlier don't support subqueries in the FROM clause. If
you're using one of those, you'll need to save the SELECT DISTINCT subquey
as a separate query, and use the saved query (instead of the SELECT DISTINCT
subquery) in the FROM clause above.



To clarify the issue of subqueries for those still using
A97, it does allow subqueries in the FROM clause (including
JOINs). It does require a different syntax though:

FROM
[SELECT DISTINCT
Dept,
ApplicationNo
FROM
YourTable]. AS T

The silly dot after the ] is required.

--
Marsh
MVP [MS Access]
  #3  
Old February 3rd, 2005, 04:50 PM
Brian Camire
external usenet poster
 
Posts: n/a
Default

You're right! I discovered the same also applies to Access 95. For some
reason I didn't think this was added until Access 2000.

Thanks for pointing this out.

"Marshall Barton" wrote in message
...
Brian Camire wrote:

You might try something like this:

SELECT
Dept,
Count(*) AS CountofApplicationNo
FROM
(SELECT DISTINCT
Dept,
ApplicationNo
FROM
YourTable)
GROUP BY
Dept

Access 97 and earlier don't support subqueries in the FROM clause. If
you're using one of those, you'll need to save the SELECT DISTINCT

subquey
as a separate query, and use the saved query (instead of the SELECT

DISTINCT
subquery) in the FROM clause above.



To clarify the issue of subqueries for those still using
A97, it does allow subqueries in the FROM clause (including
JOINs). It does require a different syntax though:

FROM
[SELECT DISTINCT
Dept,
ApplicationNo
FROM
YourTable]. AS T

The silly dot after the ] is required.

--
Marsh
MVP [MS Access]



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count unique rows and columns George Worksheet Functions 2 August 5th, 2004 06:19 PM
Conditional Unique Number Count Russel Worksheet Functions 2 March 17th, 2004 12:07 PM
count the number of unique entries in a column; with a certain filter chvandewiele Worksheet Functions 6 February 26th, 2004 10:14 AM


All times are GMT +1. The time now is 04:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.