Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2004, 05:22 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default query help

Hi

i have a table
with columns

student_number,
test1score,
test1date,
test2score,
test2date,
test3score,
test3date

i need to select the max(test1score) and the corresponding test1date
max(test2score) and corresponding test2date and the max(test3score) and corresponding test3date
all in one single query

also no restrictions on number of times a student takes a test
and test scores and dates can be NULL.

anyone any tips ?


 
Old January 24th, 2004, 08:41 PM
Authorized User
 
Join Date: Nov 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to bjackman Send a message via MSN to bjackman
Default

I think this is what you were looking for. I tried it a couple different ways. From what you wrote i'm figuring you wanted the max test 1 score from all records and so on and soforth. This worked for me. If this isn't what you wanted, repost with more information and i'll try and help. Here is the sequel string.


SELECT Max(Query1.test1score) AS MaxOftest1score, Max(Query1.Student_Number) AS MaxOfStudent_Number, Max(Query1.test1date) AS MaxOftest1date
FROM Query1;


 
Old January 26th, 2004, 04:37 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi bjackman

well thats not what i need i am posting a few values of the table
i hope my query will be clear
after that

the corresponding columns are

sid, test1scr,test1dt, test2scr,test2dt,test3scr, test3dt

("111", 300, "01/01/2004", 200, "01/02/2004", 300, "12/31/2005");
("111", 100, "01/01/2004", 200, "01/02/2004", 300, "12/31/2005");
("111", 100, "01/11/2004", 400, "01/03/2004", 233, "01/31/2005");
("111", 50, "01/01/2004", 200, "11/02/1998", 555, "11/31/2005");
("111", 50, "01/01/2009", 112, "11/02/1999", 555, "11/31/2002");

("222", 900, "01/01/2004", 600, "01/02/2004", 700, "12/31/2005");
("222", 100, "11/01/2004", 200, "10/02/2004", 700, "11/01/2002");
("222", 900, "06/01/2001", 550, "01/02/2004", 300, "12/31/2005");
("222", 100, "01/01/2004", 550, "11/02/2002", 300, "12/31/2005");
("333", 700, "07/01/2004", 600, "01/02/2004", 300, "12/31/2005");
("333", 700, "09/01/2004", 200, "11/02/2004", 150, "07/29/2005");
("333", 100, "01/01/2004", 600, "08/08/2002", 444, "06/09/2001");
("333", 100, "01/01/2004", 200, "01/02/2004", 444, "12/31/2005");

now for example sid = 111 max test 1 score will be 300
which was taken on 01/01/2004
ur query will give me 01/01/2009 which is the max test date which may not correspond to the max test score

so for id 111 i will get

111, 300, 01/01/2004, 400, "01/03/2004",555, "11/31/2005"

note that for test 3 there are 2 scores of 555 so i need the highest
date 11/31/2005

Thanks



Quote:
quote:Originally posted by bjackman
 I think this is what you were looking for. I tried it a couple different ways. From what you wrote i'm figuring you wanted the max test 1 score from all records and so on and soforth. This worked for me. If this isn't what you wanted, repost with more information and i'll try and help. Here is the sequel string.


SELECT Max(Query1.test1score) AS MaxOftest1score, Max(Query1.Student_Number) AS MaxOfStudent_Number, Max(Query1.test1date) AS MaxOftest1date
FROM Query1;







Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.