473,394 Members | 1,679 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,394 software developers and data experts.

finding the "most frequent " entry in one field for each instance in another field

I am a Access newbie... Hopefully somebody can help me figure this
out.

I have a database that looks like:

Asset Economic Minimum
----- ----------------
10555 320
10555 320
10555 320
10555 180
10555 500
30267 5
30267 5
30267 78
30267 100

I would like to be able to create a query that will give me a list of
the unique entries in the "Asset" column along with the "most
frequent" entry from the "Economic Minimum" column for each unique
"Asset" entry. The result of the query for this example would look
like:

Asset Economic Minimum
----- ----------------
10555 320
30267 5

If one could have additional columns that would give the count and/or
the frequency of the "most frequent" entry that would be even better.
The result of this query would look like:

Asset Economic Minimum Count Frequency
----- ---------------- ----- ---------
10555 320 3 .60
30267 5 2 .50
I suspect this is easy but I have never used Access before and the
Access book I have (Que: Using Access 2000) has not been much help...
Does anyone have a suggestion for a good book for learning Access?

Thanks,

ddenholm
Nov 12 '05 #1
3 2707
You need 4 queries for the complete solution. Your data is held in Table1

Query1

SELECT Table1.Asset, Count(Table1.EcQty) AS CountOfEcQty, Table1.EcQty
FROM Table1
GROUP BY Table1.Asset, Table1.EcQty;

Query2

SELECT Query1.Asset, Max(Query1.CountOfEcQty) AS MaxOfCountOfEcQty
FROM Query1
GROUP BY Query1.Asset;
Query3

SELECT Count(Table1.Asset) AS CountOfAsset, Table1.Asset
FROM Table1
GROUP BY Table1.Asset;
Query4
SELECT Query1.Asset, Query1.CountOfEcQty, Query1.EcQty, Query3.CountOfAsset,
[CountOfEcQty]/[CountOfAsset] AS [Percent]
FROM Query3 INNER JOIN (Query1 INNER JOIN Query2 ON (Query1.CountOfEcQty =
Query2.MaxOfCountOfEcQty) AND (Query1.Asset = Query2.Asset)) ON Query3.Asset
= Query2.Asset
ORDER BY Query1.Asset;

Seems to give the correct result and also shows any "ties" when the
frequency is the same

Phil
"D Denholm" <dd******@theworld.com> wrote in message
news:e7**************************@posting.google.c om...
I am a Access newbie... Hopefully somebody can help me figure this
out.

I have a database that looks like:

Asset Economic Minimum
----- ----------------
10555 320
10555 320
10555 320
10555 180
10555 500
30267 5
30267 5
30267 78
30267 100

I would like to be able to create a query that will give me a list of
the unique entries in the "Asset" column along with the "most
frequent" entry from the "Economic Minimum" column for each unique
"Asset" entry. The result of the query for this example would look
like:

Asset Economic Minimum
----- ----------------
10555 320
30267 5

If one could have additional columns that would give the count and/or
the frequency of the "most frequent" entry that would be even better.
The result of this query would look like:

Asset Economic Minimum Count Frequency
----- ---------------- ----- ---------
10555 320 3 .60
30267 5 2 .50
I suspect this is easy but I have never used Access before and the
Access book I have (Que: Using Access 2000) has not been much help...
Does anyone have a suggestion for a good book for learning Access?

Thanks,

ddenholm

Nov 12 '05 #2
Thanks... I won't pretend I understand all the SQL but it does just
what I wanted. I had tried using the Access DesignView and the Wizard
but could not figure out how to make either do what I wanted.

I will see if I can figure out the details of your SQL. If you can
recommend a good intro text to SQL I would appreciate it.

Thanks again.

--Doug
"Phil Stanton" <ph**@stantonfamily.co.uk> wrote in message news:<3f***********************@mercury.nildram.ne t>...
You need 4 queries for the complete solution. Your data is held in Table1

Query1

SELECT Table1.Asset, Count(Table1.EcQty) AS CountOfEcQty, Table1.EcQty
FROM Table1
GROUP BY Table1.Asset, Table1.EcQty;

Query2

SELECT Query1.Asset, Max(Query1.CountOfEcQty) AS MaxOfCountOfEcQty
FROM Query1
GROUP BY Query1.Asset;
Query3

SELECT Count(Table1.Asset) AS CountOfAsset, Table1.Asset
FROM Table1
GROUP BY Table1.Asset;
Query4
SELECT Query1.Asset, Query1.CountOfEcQty, Query1.EcQty, Query3.CountOfAsset,
[CountOfEcQty]/[CountOfAsset] AS [Percent]
FROM Query3 INNER JOIN (Query1 INNER JOIN Query2 ON (Query1.CountOfEcQty =
Query2.MaxOfCountOfEcQty) AND (Query1.Asset = Query2.Asset)) ON Query3.Asset
= Query2.Asset
ORDER BY Query1.Asset;

Seems to give the correct result and also shows any "ties" when the
frequency is the same

Phil
"D Denholm" <dd******@theworld.com> wrote in message
news:e7**************************@posting.google.c om...
I am a Access newbie... Hopefully somebody can help me figure this
out.

I have a database that looks like:

Asset Economic Minimum
----- ----------------
10555 320
10555 320
10555 320
10555 180
10555 500
30267 5
30267 5
30267 78
30267 100

I would like to be able to create a query that will give me a list of
the unique entries in the "Asset" column along with the "most
frequent" entry from the "Economic Minimum" column for each unique
"Asset" entry. The result of the query for this example would look
like:

Asset Economic Minimum
----- ----------------
10555 320
30267 5

If one could have additional columns that would give the count and/or
the frequency of the "most frequent" entry that would be even better.
The result of this query would look like:

Asset Economic Minimum Count Frequency
----- ---------------- ----- ---------
10555 320 3 .60
30267 5 2 .50
I suspect this is easy but I have never used Access before and the
Access book I have (Que: Using Access 2000) has not been much help...
Does anyone have a suggestion for a good book for learning Access?

Thanks,

ddenholm

Nov 12 '05 #3
If I could figure it out myself it would be marvellous.

I presume you have looked at the queries in design mode rather than SQL
which makes them somewhat clearer. You will note that the first 3 queries
are has the Total symbol on the toolbar highlighted.

Phil
"D Denholm" <dd******@theworld.com> wrote in message
news:e7**************************@posting.google.c om...
Thanks... I won't pretend I understand all the SQL but it does just
what I wanted. I had tried using the Access DesignView and the Wizard
but could not figure out how to make either do what I wanted.

I will see if I can figure out the details of your SQL. If you can
recommend a good intro text to SQL I would appreciate it.

Thanks again.

--Doug
"Phil Stanton" <ph**@stantonfamily.co.uk> wrote in message

news:<3f***********************@mercury.nildram.ne t>...
You need 4 queries for the complete solution. Your data is held in Table1
Query1

SELECT Table1.Asset, Count(Table1.EcQty) AS CountOfEcQty, Table1.EcQty
FROM Table1
GROUP BY Table1.Asset, Table1.EcQty;

Query2

SELECT Query1.Asset, Max(Query1.CountOfEcQty) AS MaxOfCountOfEcQty
FROM Query1
GROUP BY Query1.Asset;
Query3

SELECT Count(Table1.Asset) AS CountOfAsset, Table1.Asset
FROM Table1
GROUP BY Table1.Asset;
Query4
SELECT Query1.Asset, Query1.CountOfEcQty, Query1.EcQty, Query3.CountOfAsset, [CountOfEcQty]/[CountOfAsset] AS [Percent]
FROM Query3 INNER JOIN (Query1 INNER JOIN Query2 ON (Query1.CountOfEcQty = Query2.MaxOfCountOfEcQty) AND (Query1.Asset = Query2.Asset)) ON Query3.Asset = Query2.Asset
ORDER BY Query1.Asset;

Seems to give the correct result and also shows any "ties" when the
frequency is the same

Phil
"D Denholm" <dd******@theworld.com> wrote in message
news:e7**************************@posting.google.c om...
I am a Access newbie... Hopefully somebody can help me figure this
out.

I have a database that looks like:

Asset Economic Minimum
----- ----------------
10555 320
10555 320
10555 320
10555 180
10555 500
30267 5
30267 5
30267 78
30267 100

I would like to be able to create a query that will give me a list of
the unique entries in the "Asset" column along with the "most
frequent" entry from the "Economic Minimum" column for each unique
"Asset" entry. The result of the query for this example would look
like:

Asset Economic Minimum
----- ----------------
10555 320
30267 5

If one could have additional columns that would give the count and/or
the frequency of the "most frequent" entry that would be even better.
The result of this query would look like:

Asset Economic Minimum Count Frequency
----- ---------------- ----- ---------
10555 320 3 .60
30267 5 2 .50
I suspect this is easy but I have never used Access before and the
Access book I have (Que: Using Access 2000) has not been much help...
Does anyone have a suggestion for a good book for learning Access?

Thanks,

ddenholm

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bob | last post by:
I am trying to find a simple way to determine the field size of a field in an Access table. I am writing a VB.NET Windows application. I would like a code snippet that I can get to work. I found...
2
by: FLEB | last post by:
Okay, so I've got this XML: <qa> <questionset> <question name="yourname">What is your name?</question> <question name="yourquest">What is your quest?</question> <question name="favcolor"> What...
7
by: Scott W Gifford | last post by:
Hello, I'm considering using XML to represent a stream of location information, and XPath to do queries against it. I've got most of it figured out (at least on paper), but I can't figure out...
0
by: Trey | last post by:
I am trying to make a database for tracking calls, the caller gets one free call (per 12 months), then is charged a flat fee for every call after the first call in a 12 month time span. The data is...
5
by: trint | last post by:
I know that this function IS in this dll that comes with windows xp that allows bidirectional printing (you can search "bidispl.dll" on MSDN). However, I keep getting the same error all day, go to...
3
by: mosdef_underground | last post by:
How can I use C# to find the most recently modified file in a folder? As you can probably guess, I am just a beginner, so any help would be appreciated. Thanks!
8
by: | last post by:
The New York Times and many other online publications automatically generate "most popular article" lists that cover, say, the last 24 hours. I am looking for guidance and/or code on the best way...
2
by: Mukesh_Singh_Nick | last post by:
What is meant by the "most significant digits" in the following statement? <BLOCKQUOTE> With %g and %G, the precision modifier determines the maximum number of significant digits...
4
by: zacks | last post by:
Most applications whose purpose is to work with various types of files implement a "Most Recent Files" list, where the last, say, four files accessed by the application can quickly be re-opened by...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.