473,467 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

In Select Statement Sum Top 3

38 New Member
ASP 2.0/C# Access 2000 database
I need to sum the top 3 race times. Below I can get the top 3 times but now how do I sum them?

SELECT TOP 3 qryRaceTime.RaceTime FROM (Registered INNER JOIN qryRaceTime ON Registered.BibNum = qryRaceTime.BibNum AND Registered.RaceYear = qryRaceTime.RaceYear) WHERE (qryRaceTime.RaceYear = ?) AND (Registered.RunnerID = ?) ORDER BY qryRaceTime.RaceTime

In the Where statement the ? refer to drop down boxes on my form. I bascially need to add the top 3 racetimes for each runner. Where do I put the SUM in this select statement?

I have tried numerous versions and I keep coming back with errors. I know I am missing something easy but for the life of me I can't figure it out.

PLEASE HELP!

Thanks!
Jul 4 '07 #1
3 1121
r035198x
13,262 MVP
ASP 2.0/C# Access 2000 database
I need to sum the top 3 race times. Below I can get the top 3 times but now how do I sum them?

SELECT TOP 3 qryRaceTime.RaceTime FROM (Registered INNER JOIN qryRaceTime ON Registered.BibNum = qryRaceTime.BibNum AND Registered.RaceYear = qryRaceTime.RaceYear) WHERE (qryRaceTime.RaceYear = ?) AND (Registered.RunnerID = ?) ORDER BY qryRaceTime.RaceTime

In the Where statement the ? refer to drop down boxes on my form. I bascially need to add the top 3 racetimes for each runner. Where do I put the SUM in this select statement?

I have tried numerous versions and I keep coming back with errors. I know I am missing something easy but for the life of me I can't figure it out.

PLEASE HELP!

Thanks!
Moved from articles to forum section.
Jul 5 '07 #2
Vidhura
99 New Member
ASP 2.0/C# Access 2000 database
I need to sum the top 3 race times. Below I can get the top 3 times but now how do I sum them?

SELECT TOP 3 qryRaceTime.RaceTime FROM (Registered INNER JOIN qryRaceTime ON Registered.BibNum = qryRaceTime.BibNum AND Registered.RaceYear = qryRaceTime.RaceYear) WHERE (qryRaceTime.RaceYear = ?) AND (Registered.RunnerID = ?) ORDER BY qryRaceTime.RaceTime

In the Where statement the ? refer to drop down boxes on my form. I bascially need to add the top 3 racetimes for each runner. Where do I put the SUM in this select statement?

I have tried numerous versions and I keep coming back with errors. I know I am missing something easy but for the life of me I can't figure it out.

PLEASE HELP!

Thanks!
Try this

Select sum(A.RaceTime) from (SELECT TOP 3 qryRaceTime.RaceTime FROM (Registered INNER JOIN qryRaceTime ON Registered.BibNum = qryRaceTime.BibNum AND Registered.RaceYear = qryRaceTime.RaceYear) WHERE (qryRaceTime.RaceYear = ?) AND (Registered.RunnerID = ?) ORDER BY qryRaceTime.RaceTime) as A
Jul 5 '07 #3
emajka21
38 New Member
This worked, you are FANTASTIC. I have been staring at this for hours and you make it look so simple.

Thanks alot!!!!
Jul 5 '07 #4

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

Similar topics

21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
4
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT: declare @IDate smalldatetime select @IDate=col001...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
6
by: Bob Stearns | last post by:
I am getting duplicate rows back from a select distinct statement of the form: SELECT DISTINCT 'jhough', '000111', t0.bhid FROM (SELECT lots of good stuff) t0 LEFT OUTER JOIN another_table ...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
0
FishVal
by: FishVal | last post by:
Hereby I'm proposing a way of convinient work with properties containing SQL Select statements, particulary RowSource property of ComboBox and ListBox. The usual way is the following. Private...
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
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: 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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.