473,804 Members | 3,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with query

I have a query that returns:
[Name] [Event]
Turner Completion
Turner Interim 1
Kemp Completion
Steel Completion
Steel Interim 1
Steel Completion
Steel Interim 1
Webb Completion
Webb Interim 1
Wilkinson Interim 1
what I want to do is where the student has an event of completion in one
row and interim in the other to return completion OR where the student
has one row (one course only)to return either event

Itried doing a group by with a count on event as I can assume that where
two rows exist one is completion. but not sure how to extract the event
description where ther is only one row.

sql so far:
SELECT Qrygetintrimcom plist.Date, Qrygetintrimcom plist.Centre,
Qrygetintrimcom plist.[Course Code], Qrygetintrimcom plist.[Course Name],
Qrygetintrimcom plist.[Last Name], Qrygetintrimcom plist.Event
FROM Qrygetintrimcom plist;

Regards in advance
Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
5 2192
Hi Peter,

If the only values in the field are "Completion " and "Interim 1" (or
"Interim [x]"), how about a simple Totals query:

SELECT Last_Name, MIN(Event)
FROM MyQuery
GROUP BY Last_Name;

------------
LoopyNZ
------------

----------------------------
Original Message:

help with query
From: Peter
Date Posted: 9/24/2004 1:43:00 AM

I have a query that returns:
[Name] [Event]
Turner Completion
Turner Interim 1
Kemp Completion
Steel Completion
Steel Interim 1
Steel Completion
Steel Interim 1
Webb Completion
Webb Interim 1
Wilkinson Interim 1
what I want to do is where the student has an event of completion in one
row and interim in the other to return completion OR where the student
has one row (one course only)to return either event

Itried doing a group by with a count on event as I can assume that where
two rows exist one is completion. but not sure how to extract the event
description where ther is only one row.

sql so far:
SELECT Qrygetintrimcom plist.Date, Qrygetintrimcom plist.Centre,
Qrygetintrimcom plist.[Course Code], Qrygetintrimcom plist.[Course Name],
Qrygetintrimcom plist.[Last Name], Qrygetintrimcom plist.Event
FROM Qrygetintrimcom plist;

Regards in advance
Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
I tried but that failed. I will explain more clearly

each student does a course and the events are interim (due an interim
payment before course end) and then completed in which case they are
entitled to all the finding.

each student can have 1 or two events

in my pasted rows example one row had interim against student A and a
row completed against student A.

student B with one row as interim
student c with one row as completed.

I need the completed row where 2 events exist (interim and completed)
and the 1 row where the row is interim or complete.


Regards in advance
Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
Peter <pe**********@d evdex.com> wrote in
news:41******** **************@ news.newsgroups .ws:
I tried but that failed. I will explain more clearly

each student does a course and the events are interim (due an
interim payment before course end) and then completed in which
case they are entitled to all the finding.

each student can have 1 or two events

in my pasted rows example one row had interim against student
A and a row completed against student A.

student B with one row as interim
student c with one row as completed.

I need the completed row where 2 events exist (interim and
completed) and the 1 row where the row is interim or complete.

If your events were numeric, with 1 representing interim and 2
indicating complete, and the descriptions in a lookup table, you
could simply build a query to return the maximum event for each
student ID. and use a combobox to show the event description on
your form.

doing it with a count might work by building an expression around
the count of rows to drive an iif() statement as in
expr1: iif(count([EVENT])=2,"Completion ",[event])

By thew way, your system will return erroneous results if you
have 2 or more students named "Smith"

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4


Regards in advance
Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5
Thanks Bob

In the end I took the event field out (as I only needed the name and the
course) then grouped to get rid of the duplicate row.

what I was left with was the correct number of students that had interin
or completion.

However I prefer your methods and will use the numeric method.

Thank you!
Regards in advance
Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6

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

Similar topics

11
4016
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
9
3140
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
9
4361
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my predecessor, I hasten to add) so that each day it creates a copy of the record for each company, changes the date to today's date, and prompts the user for any changes of ratings on that day. The resulting data table grows by approx 600 records per...
8
19604
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
5
2205
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table, all has gone very well with one exception. The table is based on applications made by potential customers looking to buy franchise rights to particular locations and as part of the process they are asked to list their preferred locations 1 to 4....
4
2862
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table query. I'm having trouble doing it. Help! Here is my code so far: Sub OldRegionQuery()
6
6439
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the Autoexec Macro looks like the way to go. Could someone please assist? Thank you very much! Mike
3
3344
by: mcmahonb | last post by:
Hey people... I've been searching this forum for a few hours and even though this topic has been went over from many different angles; I cannot seem to figure out how to make things work on my side. I am trying to learn how to manipulate Dynamic Queries by forms via the example database: QrySampl.MDB, offered by Microsoft (as a learning tool, I suppose.) In particular, I am working with code from the example: "Query By Form (QBF) Using...
4
2025
by: n | last post by:
Hello! Here is a problem I hope you can point me to a solution. It Problem: A teacher needs to know which lesson to teach. A school has a curriculum with 26 lessons, A-Z. For a given class, a random number of students arrive, each of which has completed a random number of lessons taken at random from the curriculum.
47
2889
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could help. I work in a library and send out dual language books to babies of dual or other nationality. The db is to be used for logging a range of book titles and numbers ordered and books sent out to individuals. I am trying to work out a way of...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10569
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9140
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.