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

basic help to start me to get my queries running

emandel
65
Ok in a a nutshell here is my database
I have a table called 'contacts' that has basic contact and demographics about my members

I have a table called 'events' that lists the events and info about them (date, teacher, location, price)

I have a junction table called attendance where it records who came to what.

Here is what I need.

I want the quary to tell me who the most active people that are coming to events are, what they are coming to, how many events they are coming to, Idealy I would want to run this quary once a month or so, and have it answer these questions. Also Idealy I would want a form to say

Are you looking for the top (x) people?
What age range? (all or specific)
What marital status?
What date range are you looking at activity?



I don't really know where to start.
Jan 2 '07 #1
12 1431
emandel
65
Anyone care to help me?
Jan 2 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
Ok in a a nutshell here is my database
I have a table called 'contacts' that has basic contact and demographics about my members

I have a table called 'events' that lists the events and info about them (date, teacher, location, price)

I have a junction table called attendance where it records who came to what.

Here is what I need.

I want the quary to tell me who the most active people that are coming to events are, what they are coming to, how many events they are coming to, Idealy I would want to run this quary once a month or so, and have it answer these questions. Also Idealy I would want a form to say

Are you looking for the top (x) people?
What age range? (all or specific)
What marital status?
What date range are you looking at activity?



I don't really know where to start.
You start by designing a query to return all records. When you have this query designed post it with the four questions above and we will tell you how it needs to be adapted for each.

Mary
Jan 2 '07 #3
emandel
65
OK here is the query that brings up all records:

Expand|Select|Wrap|Line Numbers
  1. SELECT Participants.[First Name], Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status], Events.Name, Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator, Events.Price
Here are my questions for starters

1) get it to show me only the top 50 attenders in the past month/3 months/year
2) get it to show me how many events they attended in that time period and have that broken down by lets say the [events.type]
Jan 2 '07 #4
emandel
65
any help here?
Jan 2 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
OK here is the query that brings up all records:

Expand|Select|Wrap|Line Numbers
  1. SELECT Participants.[First Name], Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status], Events.Name, Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator, Events.Price
Here are my questions for starters

1) get it to show me only the top 50 attenders in the past month/3 months/year
2) get it to show me how many events they attended in that time period and have that broken down by lets say the [events.type]

SELECT TOP 50 Participants.[First Name], Participants.[Last Name],
First question - What are you basing the top 50 on, a count of the number of events attended or what?
Participants.Birthdate, Participants.[Marital Status], Events.Name,
Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator,
Events.Price
FROM Participants INNER JOIN Events
ON Participants.?????????? = Events.??????????????
Second question - What is the field in common with the two tables
WHERE Month(Events.Date) = IIf(Month(Date())=1,12,Month(Date())-1)
This will return records for the previous calendar month

This may need further order by or group by statements but I will need the answer to the above questions first.

Mary
Jan 2 '07 #6
emandel
65
Your first question - yes I want the 50 most active participants the ones that have come to the most events.

There is a third table that is not currently in this query that links the two tables together. Basicaly it lists which participants came to which events.
Jan 2 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
Your first question - yes I want the 50 most active participants the ones that have come to the most events.

There is a third table that is not currently in this query that links the two tables together. Basicaly it lists which participants came to which events.
Ok, I need to know the two fields from the third table that link to each of the other tables.

Also we will need to build two queries. One to get the count of the number of events a participant attends and display the top 50. Then the other query can return the related fields for each event the participant attended.

Mary
Jan 2 '07 #8
emandel
65
Events.[ID] and participants.[ID]

in other words both are called "ID" one is from the events table and one is from in the participants table.

In the "atendance" table (which is the junction table) those fields are named "event" and "atendee"
Jan 2 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
Events.[ID] and participants.[ID]

in other words both are called "ID" one is from the events table and one is from in the participants table.

In the "atendance" table (which is the junction table) those fields are named "event" and "atendee"
The first query will be:

Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 50 participants.[ID], Participants.[First Name], 
  2. Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status], 
  3. Count(atendance.event) As NumEventsAttended
  4. FROM Participants INNER JOIN atendance
  5. ON Participants.[ID] = atendance.atendee
  6. GROUP BY participants.[ID], Participants.[First Name], Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status]
  7. ORDER BY Count(atendance.event);
  8.  
This will return the top 50 participants ...for now I'm naming the query 'qryTop50Participants'

The next query will be:

Expand|Select|Wrap|Line Numbers
  1. SELECT qryTop50Participants.[First Name], qryTop50Participants.[Last Name], qryTop50Participants.Birthdate, qryTop50Participants.[Marital Status], Events.Name,  
  2.  Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator, 
  3.  Events.Price
  4.  FROM ((qryTop50Participants INNER JOIN atendance
  5.  ON qryTop50Participants.[ID] = atendance.atendee)
  6. INNER JOIN Events ON atendance.event = Events.[ID])
  7.  WHERE Month(Events.Date) = IIf(Month(Date())=1,12,Month(Date())-1)
  8.  
This will return records for the previous calendar month
Jan 2 '07 #10
NeoPa
32,556 Expert Mod 16PB
Anyone care to help me?
any help here?
Emandel,
We all need to bump threads from time to time when questions are still outstanding and a number of days have passed since any activity.
Bumping a thread after little more than an hour is not something I'm happy with and is likely to win you no friends among the experts on this site.
Please wait at least a whole day before bumping threads in future.

MODERATOR.
Jan 2 '07 #11
emandel
65
First of all,
Thank you for the pointer, I certainly don't want to be percieved as pushy. Now I know the guidelines.

Mary:

The first query will be:

Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 50 participants.[ID], Participants.[First Name], 
  2. Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status], 
  3. Count(atendance.event) As NumEventsAttended
  4. FROM Participants INNER JOIN atendance
  5. ON Participants.[ID] = atendance.atendee
  6. GROUP BY participants.[ID], Participants.[First Name], Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status]
  7. ORDER BY Count(atendance.event);
  8.  
This will return the top 50 participants ...for now I'm naming the query 'qryTop50Participants'

The next query will be:

Expand|Select|Wrap|Line Numbers
  1. SELECT qryTop50Participants.[First Name], qryTop50Participants.[Last Name], qryTop50Participants.Birthdate, qryTop50Participants.[Marital Status], Events.Name,  
  2.  Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator, 
  3.  Events.Price
  4.  FROM ((qryTop50Participants INNER JOIN atendance
  5.  ON qryTop50Participants.[ID] = atendance.atendee)
  6. INNER JOIN Events ON atendance.event = Events.[ID])
  7.  WHERE Month(Events.Date) = IIf(Month(Date())=1,12,Month(Date())-1)
  8.  
This will return records for the previous calendar month
The first query is working but for the second query what I want is the top 50 people for the past month (or another date that I will put into the parametar). What the query is giving me is the 50 most overall attenders (since the beginning of the recorded events) and than from those 50 giving me when they came over the past month.

I think that the second query needs to come first. i.e. who came at all in the past month, and from those give the me the 50 top attenders and how many times they came.
for that first (or second the way you had it) query I want to have a parameter where when I run it I tell it what the date range is: so it asks me "For the past how many days?"
Jan 2 '07 #12
MMcCarthy
14,534 Expert Mod 8TB

The first query is working but for the second query what I want is the top 50 people for the past month (or another date that I will put into the parametar). What the query is giving me is the 50 most overall attenders (since the beginning of the recorded events) and than from those 50 giving me when they came over the past month.

I think that the second query needs to come first. i.e. who came at all in the past month, and from those give the me the 50 top attenders and how many times they came.
for that first (or second the way you had it) query I want to have a parameter where when I run it I tell it what the date range is: so it asks me "For the past how many days?"
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 50 participants.[ID], Participants.[First Name],
  2. Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status],
  3. Count(atendance.event) As NumEventsAttended
  4. FROM ((Participants INNER JOIN atendance
  5. ON Participants.[ID] = atendance.atendee)
  6. INNER JOIN Events ON atendance.event = Events.[ID])
  7. WHERE Events.Date BETWEEN Date()-[For the past how many days?] AND Date()
  8. GROUP BY participants.[ID], Participants.[First Name], Participants.[Last Name], Participants.Birthdate, Participants.[Marital Status];
  9.  
This should return Top 50 participants and a count of how many events each attended ...for now I'm naming the query 'qryEventsAttended'

The next query will be:

Expand|Select|Wrap|Line Numbers
  1. SELECT qryEventsAttended.NumEventsAttended, qryEventsAttended.[First Name], qryEventsAttended.[Last Name], qryEventsAttended.Birthdate, qryEventsAttended.[Marital Status], Events.Name, Events.Date, Events.time, Events.Type, Events.Subject, Events.Educator, Events.Price 
  2. FROM ((qryEventsAttended INNER JOIN atendance
  3. ON qryEventsAttended.[ID] = atendance.atendee)
  4. INNER JOIN Events ON atendance.event = Events.[ID]);
  5.  
Mary
Jan 3 '07 #13

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

Similar topics

17
by: Gabriel Mejía | last post by:
Services or applications using ActiveX Data Objects (ADO) 2.0 or greater may intermittently return empty recordsets on queries that should be returning valid results. At the time the problem...
12
by: Nick Stansbury | last post by:
Hi, Access 2003. Running over terminal server on a Windows Server 2003 box. The error occurs on every machine that I've tried copying the file to. Latest Jet SP & Office SP. Database hasn't been...
1
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
0
by: =?Utf-8?B?S29uc3RhbnRpbg==?= | last post by:
I am currently working on the application that need to simulate basic authentication programmatically using user's credentials that are known. Basically, the need is for a single sign on with a...
3
by: JJ | last post by:
I've done a little multi-threading on winform apps some time ago now, so I'm not a complete beginner, but best assume I am for any explanations..: This is an asp.net 2.0 website, using c#: I...
28
by: Randy Reimers | last post by:
(Hope I'm posting this correctly, otherwise - sorry!, don't know what else to do) I wrote a set of programs "many" years ago, running in a type of basic, called "Thoroughbred Basic", a type of...
4
by: JB | last post by:
Hi All, I need to write my first "distributed" application and due to my lack of knowledge and experience in that area, I'm stuck on the first big design decision. Reading a lot on distributed...
43
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.