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

Home Posts Topics Members FAQ

SQL (or query question)

I have a query in Access 2000 like this:

SELECT [games].[team1], [games].[points team1], [games].[length],
[games].[overtime], [games].[overtime length], [games].[team2],
[games].[points team2]
FROM games
WHERE team1="USC" or team2="USC";

This is based on a game I played years ago. We created "tournament s" where
the top college football teams
of the 1960, would play each other.

The games had different lengths depending on what round the games were in
(shorter games with all 32 teams
playing and longer when the 16 teams etc.). In addition some of the games
went to overtime.

We sorted them by hand by percantage, how few points the "defense" of the
team would score and then
by how many the "Offense scored"

What I would like to do, is somehow work the query so that I don't have to
worry if the team is "team1" or
"eam2". I also want to sum all the points the defense allowed so I can find
a stat ("I call Points allowd per minutes). I also want to sum all the
offense points from all as well.

Can I get this information with one query? It could save me on writing CPP
code.


Jul 9 '06 #1
1 1361
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Your design of the Games table is incorrect. It should be like this:

CREATE TABLE Games (
game_nbr INT NOT NULL ,
team_name CHAR(5) NOT NULL -- just use initials "USC", "UCLA", etc.
REFERENCES Teams (team_name)
ON DELETE CASCADE ,
final_score INT NOT NULL ,
game_length DATETIME NOT NULL ,
CHECK (game_length BETWEEN #00:01# And #23:59#)
overtime_length DATETIME NULL -- NULL means no overtime
CHECK (overtime_lengt h BETWEEN #00:01# And #23:59#),
CONSTRAINT PK_Games PRIMARY KEY (game_nbr, team_name)
)

The game_length & overtime_length columns would hold only times, not
dates.

If you were using overtime as a Yes/No field, then you don't need it.
Any value, other than zero, in the overtime_length indicates there was
overtime played.

The CHECK constraints are for illustration only. They are the column's
(Access calls them Fields) Validation property.

If you want to keep track of games over more than one season add a
season_year colum to the table and make it part of the Primary Key.
E.g.:

....
season_year INT NOT NULL
CHECK (season_year 1959)
....
CONSTRAINT PK_Games PRIMARY KEY (game_nbr, team_nbr, season_year)

Your query doesn't match the criteria you describe in your post - it
just shows the teams & there final scores - no percentages, etc. Since
football defense & offense changes according to who has possession of
the ball you'd have to have more detail, probably another table, showing
the changes between offense & defense per team & the scoring while each
team was in each role. Usually, a team only scores when in the
offensive role. By offense & defense, do you mean visiting team and
home team, respectively? If so you can add another column to the table
indicating their role "Visitor" or "Home." E.g.:

team_role CHAR(1) NOT NULL CHECK team_role IN ('V', 'H') ,

It would also be part of the Primary Key, just add the column_name to
the others in the PK constraint definition.

To find out scores for USC when they were Visitors, sorted highest to
lowest, you'd have a query like this:

SELECT game_nbr, final_score
FROM Games
WHERE game_name = "USC"
AND team_role = "V"
ORDER BY final_score DESC

--
MGFoster:::mgf0 0 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRLF154echKq OuFEgEQJB1QCff/wgoyb2TLpugn5AS FzPg6HQZ/8AoNGc
UQMbzvFSr6K/QQIGuIm67VKS
=BdCs
-----END PGP SIGNATURE-----
mm*******@usfam ily.net wrote:
I have a query in Access 2000 like this:

SELECT [games].[team1], [games].[points team1], [games].[length],
[games].[overtime], [games].[overtime length], [games].[team2],
[games].[points team2]
FROM games
WHERE team1="USC" or team2="USC";

This is based on a game I played years ago. We created "tournament s" where
the top college football teams
of the 1960, would play each other.

The games had different lengths depending on what round the games were in
(shorter games with all 32 teams
playing and longer when the 16 teams etc.). In addition some of the games
went to overtime.

We sorted them by hand by percantage, how few points the "defense" of the
team would score and then
by how many the "Offense scored"

What I would like to do, is somehow work the query so that I don't have to
worry if the team is "team1" or
"eam2". I also want to sum all the points the defense allowed so I can find
a stat ("I call Points allowd per minutes). I also want to sum all the
offense points from all as well.

Can I get this information with one query? It could save me on writing CPP
code.
Jul 9 '06 #2

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

Similar topics

16
2728
by: cover | last post by:
I have a form with drop down menus to query for name, month, and year to capture activity accordingly by an individual for a given month and given year. But I'd like to also be able to query ALL individiduals for a given month and year OR an individual for the whole year for example. My question, is there any way to have blank (not filled in) fields of a query input ignored when left blank? I'm currently doing very successfully what I...
4
22700
by: Spark | last post by:
Hi, Situation: Need a query to return number of ticket records by month of open in a log table where the ticket open record is older than 24 hours then the ticket pending or ticket closed record. Tickets can also only have a closed record with no open record. Sample data table: ticket_id date_log status_name status_id
3
1507
by: MX1 | last post by:
Here's a simple query question. I have tables. One is an order table and one is an order detail table. tOrder tOrderDetail The tOrder table contains basic info like customer name, date, a flat rate, etc. The tOrderDetail table is linked to tOrder by a field called DetailID. Some orders in the tOrderDetail table actually have related data in the tOrderDetail table. I'm trying to write a simple query that will capture
1
4652
by: Jaycee66 | last post by:
Access 2000 "Between" query question: I am relatively new to MS Access and everytime I think I have a basic concept of the program it pokes me in the eye with something I think would be simple to create. I want to create 2 separate queries for a label. I would like to have the query prompt me for the date I choose to start from until the present date and the other to prompt me for the date I choose to start from and 2 additional numbers...
2
1310
by: Erica | last post by:
Hi All, I've searched the usenet/web high and low and cant seem to find any guidelines for the query i'm trying to write. I have made a database that contains all my invoices. Invoices that contain the status "DUE" are then displayed on a report. My question is this. I have about 50 companies in there now and Have my report set up to break pages after each one.
7
6344
by: Scott Frankel | last post by:
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color | date --------+------------ red | 2004-01-19 blue | 2004-05-24
3
1958
by: cover | last post by:
I have a table with 50 fields that receive input depending on whether that input came in from a 'shaker' form or a 'conveyor' form. Input from the 'conveyor' form might populate 25 fields while input from the 'shaker' form will populate another 20-25 fields but not the same fields (however there are about 10 common fields to both). I'd thought about using two tables (one for 'conveyor' and the other for 'shaker') but thought I'd try just...
10
2094
by: Robert | last post by:
I am an attorney in a non-profit organization and a self-taught programmer. I'm trying to create a client db that will allow me to search for potential conflicts of interest based either on Social Security # or on Last Name. I've created two different tables with the following fields in each table: ClientInfo Client# (primary key) First Name Middle Name Last Name
2
1209
by: Grip | last post by:
Just started teaching myself Access and I've got a newbie question... I have two tables tblPpl and tblOrgs linked by a many-to-one relationship. I'm trying to produce a report that will show a list of people's names and their organizations. I've built a query to base the report on with three columns, LastName from tblPpl, FirstName from tblPpl and OrgName from tblOrgs. The problem I'm having is the query does not 'find' people who...
3
1830
by: bob laughland | last post by:
Hi All, I have another SQL question, and this one is going to be difficult to explain. I have a table like this rowid name changed 1 a 1 1 b 0
0
8443
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
8356
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,...
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,...
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
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?
1
2769
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 we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
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.