473,468 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Create 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,
CompetitionPlace, 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, CompetitionPlace 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 3984
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.google.c om...
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,
CompetitionPlace, 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, CompetitionPlace 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,AthleteID.

SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions
ON Competitions.CompetitionID=Scores.CompetitionID INNER JOIN
Athlets ON Athletes.AthleteID=Scores.AthleteID
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*************************************@mygat e.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,AthleteID.

SELECT TOP <how-many-best> AthletsName, Min(Score)
FROM Scores INNER JOIN Competitions
ON Competitions.CompetitionID=Scores.CompetitionID INNER JOIN
Athlets ON Athletes.AthleteID=Scores.AthleteID
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
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...
0
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...
3
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...
69
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000);...
11
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...
6
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. ...
0
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. ...
8
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...
27
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
1
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
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...
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,...
0
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
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 ...

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.