473,666 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List of best athlets and not best scores. Problem with SQL command

Hi all,

I have set up a simple VB program (and later on an ASP interface) to
manage an Athletics database. I'm using Access 2000.

To simplify, I have the Athlets, the Competitions and the Scores
tables.

When I want to list of the best scores/ranking, I just do:

SELECT TOP <how-many-best> AthletsName, Competitiondate ,
CompetitionPlac e, Score
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
ORDER BY Score [DESC]

([DESC] is present if the scores are measured in times and not if they
are lengths)

I come into a problem whehter I want to list the best athlets, so to
say listing just the best results for each Athlet.

If I add a group by Athletsname parameter in the SQL, I am not any
longer able to display Competitiondate , CompetitionPlac e because they
are not part of the aggregate function. :-(
So to say, I can only do:
---
SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
GROUP BY AthletsName
ORDER BY Min(Score)

for scores in time

SELECT TOP <how-many-best> AthletsName, Max(Score)
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
GROUP BY AthletsName
ORDER BY Max(Score)

for scores in lenght
---

How can I do, which SQL command can I use to be able to view all the
fields of the first SQL with just the best Athlets and not all the
best scores?

Many thanks for your replies.

Best regards,
Irene
Nov 12 '05 #1
3 3994
TC
Questions like this are fundamentally dependent on what is the primary key
of each table.

You need to say what is the primary key of each table.

TC
Irene <it************ @hotmail.com> wrote in message
news:cc******** *************** ***@posting.goo gle.com...
Hi all,

I have set up a simple VB program (and later on an ASP interface) to
manage an Athletics database. I'm using Access 2000.

To simplify, I have the Athlets, the Competitions and the Scores
tables.

When I want to list of the best scores/ranking, I just do:

SELECT TOP <how-many-best> AthletsName, Competitiondate ,
CompetitionPlac e, Score
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
ORDER BY Score [DESC]

([DESC] is present if the scores are measured in times and not if they
are lengths)

I come into a problem whehter I want to list the best athlets, so to
say listing just the best results for each Athlet.

If I add a group by Athletsname parameter in the SQL, I am not any
longer able to display Competitiondate , CompetitionPlac e because they
are not part of the aggregate function. :-(
So to say, I can only do:
---
SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
GROUP BY AthletsName
ORDER BY Min(Score)

for scores in time

SELECT TOP <how-many-best> AthletsName, Max(Score)
FROM Scores INNER JOIN Competitions ... INNER JOIN Athlets ...
GROUP BY AthletsName
ORDER BY Max(Score)

for scores in lenght
---

How can I do, which SQL command can I use to be able to view all the
fields of the first SQL with just the best Athlets and not all the
best scores?

Many thanks for your replies.

Best regards,
Irene

Nov 12 '05 #2
"TC" <a@b.c.d> wrote in message news:1064729294 .712637@teuthos
Questions like this are fundamentally dependent on what is the primary key
of each table.

You need to say what is the primary key of each table.

TC


Glad to know.
Athletes - PK AthleteID
Competitions - PK CompetitionID
SCORES - no PK. FK CompetionID,Ath leteID.

SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions
ON Competitions.Co mpetitionID=Sco res.Competition ID INNER JOIN
Athlets ON Athletes.Athlet eID=Scores.Athl eteID
GROUP BY AthletsName
ORDER BY Min(Score)

Thanks
Irene

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Nov 12 '05 #3
TC

Ok. I say there is a problem with SCORES.

Please tell me the fields in that table.

TC
Irene <it************ @hotmail.com> wrote in message
news:f4******** *************** **************@ mygate.mailgate .org...
"TC" <a@b.c.d> wrote in message news:1064729294 .712637@teuthos
Questions like this are fundamentally dependent on what is the primary key of each table.

You need to say what is the primary key of each table.

TC


Glad to know.
Athletes - PK AthleteID
Competitions - PK CompetitionID
SCORES - no PK. FK CompetionID,Ath leteID.

SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions
ON Competitions.Co mpetitionID=Sco res.Competition ID INNER JOIN
Athlets ON Athletes.Athlet eID=Scores.Athl eteID
GROUP BY AthletsName
ORDER BY Min(Score)

Thanks
Irene

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Nov 12 '05 #4

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

Similar topics

12
1526
by: Nickolay Kolev | last post by:
Hi all, I would like to find a more pythonic way of solving the following: Having a string consisting of letters only, find out the total sound score of the string. The sound score is calculated as the sum of the transition scores between the characters in that string. The transition scores are stored in a 26 x 26 matrix. I.e. the transition A -> F would have the score soundScoreMatrix.
0
1910
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the desired key value, and then make the entry with the desired join key in the 'many-only' table." ... happens when I click on an entry of a combobox. HELP!! Here's the background:
3
2328
by: sugaray | last post by:
hi, i have to build a linked-list which has another sturcture _score as it's data entry, so how can i sort such linked-list based on, let say, history score into proper order (descending/ascending). thanx for your help ! struct _score { float literature; float history; float sociology; };
69
16834
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000); ------------------------------------------------------------ Here is the HTML that I'm producing:
11
1445
by: Bart Van Loon | last post by:
Hi all, I would like to find out of a good way to append an element to a list without chaing that list in place, like the builtin list.append() does. currently, I am using the following (for a list of integers, but it could be anything, really) #-------------------------------------------------- def addnumber(alist, num):
6
2920
by: Shawn Minisall | last post by:
I'm writing a game that uses two functions to check and see if a file called highScoresList.txt exists in the main dir of the game program. If it doesn, it creates one. That part is working fine. The problem is arising when it goes to read in the high scores from the file when I play again. This is the error msg python is giving me Traceback (most recent call last): File "<pyshell#0>", line 1, in <module>
0
1209
by: Shawn Minisall | last post by:
I'm writing a game that uses two functions to check and see if a file called highScoresList.txt exists in the main dir of the game program. If it doesn, it creates one. That part is working fine. The problem is arising when it goes to read in the high scores from the file when I play again. ------------------------------------------------ 15 SHAWN 0 0
8
15283
by: d24706 | last post by:
Hello, I hope someone can help me. I had to do the following assignment( i have most of it done just cant finish it off, question and source code below). Question? Write a Java program that asks the user to input the scores, as a percentage( e.g 87.4), of 10 students. The scores entered must be stored ina n array. The programme must determine: The lowest score and its equivalent grade (ie A,B,etc)
27
2098
by: Mark | last post by:
Hi all, I have a scenario where I have a list like this: User Score 1 0 1 1 1 5 2 3 2 1
0
8866
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
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
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
6192
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
5663
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
4198
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...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.