473,512 Members | 15,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Max of Count

5 New Member
Hi,

I use access to query a Jet database full of info about members of a club.

Each attendance by each member at any of 18 sites is recorded in a table called qptHisAttendance

I'm trying to create a query that will list each member ID in the first column and the site ID for the site they've visited most in the last 30 days.

So far I've got two queries. The first lists all the visits made by a member in the past 31 days. The next one takes that list and gives a count by site ID

I want a third that just shows the Member ID and the Site ID (for the site that has the highest count in query 2).

Query 1 (called "qryBP_SiteMostVisited1") looks like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT qptHisAttendance.MemberId, qptHisAttendance.AtDate AS AttendDate, qptHisAttendance.SiteID
  2. FROM qptHisAttendance
  3. GROUP BY qptHisAttendance.MemberId, qptHisAttendance.AtDate, qptHisAttendance.SiteID
  4. HAVING (((qptHisAttendance.MemberId)=13500741) AND ((qptHisAttendance.AtDate)>=Now()-31));
Query 2 (called "qryBP_SiteMostVisited2") looks like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT [qryBP_SiteMostVisited1].MemberId, [qryBP_SiteMostVisited1].SiteID, Count([qryBP_SiteMostVisited1].SiteID) AS CountOfSiteID
  2. FROM [qryBP_SiteMostVisited1]
  3. GROUP BY [qryBP_SiteMostVisited1].MemberId, [qryBP_SiteMostVisited1].SiteID;
Can anyone help with what query 3 should look like to just display the member ID and the Site ID for the site with the highest count of attendances please?

Cheers

Bob
May 30 '07 #1
2 2629
Rabbit
12,516 Recognized Expert Moderator MVP
I only read the last few lines but can't you just use Max()?
May 30 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Bob,

Try this and see if it gives you the result you want.
Expand|Select|Wrap|Line Numbers
  1. SELECT First([qryBP_SiteMostVisited2].MemberId), First([qryBP_SiteMostVisited2].SiteID), Max([qryBP_SiteMostVisited2].CountOfSiteID)
  2. FROM qryBP_SiteMostVisited2
  3.  
Mary
Jun 2 '07 #3

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

Similar topics

22
61341
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
6
34450
by: Geetha | last post by:
I searched in the Oracle documents what count (1) meant and I could not find an answer. Can some one explain what Oracle does internally when use count (1) VS count (*). Thank you very much in...
1
3132
by: JD | last post by:
Hi guys I'm trying to write a program that counts the occurrences of HTML tags in a text file. This is what I have so far: #include <stdio.h> #include <stdlib.h> #include <string.h> ...
5
5902
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
23
2861
by: Gary Wessle | last post by:
Hi I have a vector<charwhich looks like this (a d d d a d s g e d d d d d k) I need to get the biggest count of consecutive 'd'. 5 in this example I am toying with this method but not sure if...
1
4502
by: heckstein | last post by:
I am working in Access 2002 and trying to create a report from our company's learming management system. I am not a DBA and most of my SQL knowledge has been self taught through trial and error. I...
22
12425
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
3089
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php,...
7
2529
by: Chris | last post by:
I am trying to increase/decrease the value of $_SESSION by 1 after clicking on a link e.g index.php?gotoWk=nxtWk and index.php? gotoWk=lstWk. I'm sure you will get the drift if you look at the code...
1
3596
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
7432
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...
1
7093
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
7517
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...
1
5077
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...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.