Simple Query Question

C

Chuck Hildebrandt

I want to query for all MLB pitchers who won 20 games and batted at least
..300 in the same season.

I successfully linked my Pitchers and Batters table and inserted the
calculated field for batting average ([H]/[AB]), ran the query, and it
worked. So then , so far so good.

However, when I went back and tried to limit the records returned on the
query to >=.3 on batting averages, or even when I tried to sort the query
results by batting average in the datasheet view, I got the dialog box that
says "Overflow".

Why does this happen? What is the purpose of it? How do I get around it
short of copying my query results into Excel and sorting it manually there?

Thanks.

Chuck
 
T

Tom Wickerath

Chuck,

You posted this question in the Queries newsgroup at 4:13 PM PST. You
received answers from two Microsoft Access MVP's. You really should continue
with that thread, rather than cross post. Cross posting is considered rude.
It's okay to multipost, when appropriate, but cross posting should be
avoided. If you absolutely must cross post, you should clearly indicate in
the post that you already asked your question in another newsgroup, and it
went unanswered.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
T

Tom Wickerath

http://www.microsoft.com/office/com...ries&mid=6f31e90d-d9f5-4daa-ab70-8e65edf1c9d2


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


Tom Wickerath said:
Chuck,

You posted this question in the Queries newsgroup at 4:13 PM PST. You
received answers from two Microsoft Access MVP's. You really should continue
with that thread, rather than cross post. Cross posting is considered rude.
It's okay to multipost, when appropriate, but cross posting should be
avoided. If you absolutely must cross post, you should clearly indicate in
the post that you already asked your question in another newsgroup, and it
went unanswered.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


Chuck Hildebrandt said:
I want to query for all MLB pitchers who won 20 games and batted at least
..300 in the same season.

I successfully linked my Pitchers and Batters table and inserted the
calculated field for batting average ([H]/[AB]), ran the query, and it
worked. So then , so far so good.

However, when I went back and tried to limit the records returned on the
query to >=.3 on batting averages, or even when I tried to sort the query
results by batting average in the datasheet view, I got the dialog box that
says "Overflow".

Why does this happen? What is the purpose of it? How do I get around it
short of copying my query results into Excel and sorting it manually there?

Thanks.

Chuck
 
C

Chuck Hildebrandt

What the hell are you talking about? I posted it here at 1059pm.

Tom Wickerath said:
Chuck,

You posted this question in the Queries newsgroup at 4:13 PM PST. You
received answers from two Microsoft Access MVP's. You really should
continue
with that thread, rather than cross post. Cross posting is considered
rude.
It's okay to multipost, when appropriate, but cross posting should be
avoided. If you absolutely must cross post, you should clearly indicate in
the post that you already asked your question in another newsgroup, and it
went unanswered.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________


Chuck Hildebrandt said:
I want to query for all MLB pitchers who won 20 games and batted at least
..300 in the same season.

I successfully linked my Pitchers and Batters table and inserted the
calculated field for batting average ([H]/[AB]), ran the query, and it
worked. So then , so far so good.

However, when I went back and tried to limit the records returned on the
query to >=.3 on batting averages, or even when I tried to sort the query
results by batting average in the datasheet view, I got the dialog box
that
says "Overflow".

Why does this happen? What is the purpose of it? How do I get around it
short of copying my query results into Excel and sorting it manually
there?

Thanks.

Chuck
 
T

Tom Wickerath

Then I suspect that your system clock is off (slow) by about 5 minutes. You
said you posted here at 10:59pm. Not knowing what time zone you are in, but
comparing this quoted time with the time of your initial post as displayed to
me (9:06 PM PST), I can only guess that 9:06 PM corresponds to 11:06 PM your
time. You do know what PST stands for don't you? It's Pacific Standard Time.

So, you are saying that another person who goes by the sign-in name of
"pskwaak" must have posted a very similar question dealing with baseball
statistics, with a similar Overflow error message, and even used some of the
same abbreviations that you used in this thread (ie. [h] and [ab] in square
brackets)? I find that kind of hard to believe. In any case, go read the
answers provided by Ken Snell and Doug Steele. The same answer is valid for
your question (since it's basically the same question!). Here's that link one
more time:

http://www.microsoft.com/office/com...ries&mid=6f31e90d-d9f5-4daa-ab70-8e65edf1c9d2



Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
C

Chuck Hildebrandt

Complete missing paragraph:

Try to think about this logically: why would I bother cross-posting the same
question a second time, in a more verbose manner (ten times as many lines),
rather than simply copying the question from the first post and pasting it
in for the second post?


<snip>
 
C

Chuck Hildebrandt

Tom:

Thank you very much. Your response is very refreshing and unusual for
Usenet, which at times can devolve into little better a schoolyard fight. I
apologize for my own strong reaction -- I guess it just hit me a certain way
this time. Not an excuse, just an explanation.

On the actual issue at hand, the "overflow" issue -- it was half helpful. I
was able to run the query successfully and to sort the resulting table by
batting average, but I was not able to add a filtering criterion to a
calculated field prior to running the query.

I used the Lahman 5.3 table from www.baseball1.com. Here are the actual
attributes I used:

Master.playerID
Batting.yearID
Batting.teamID
Batting.AB: <>0
Batting.H
Piching.W: >=20
AVE: Batting.[H]/[AB]

I ran this query and it executed successfully.

But when I tried to filter the AVE attribute to return only those records of
pitchers who also bating over .300 while winning 20 games, in this way:

Master.playerID
Batting.yearID
Batting.teamID
Batting.AB: <>0
Batting.H
Piching.W: >=20
AVE: Batting.[H]/[AB]: >=0.3

I got the Overflow message again.

What's the difference here? By the way, I interrelated the playerID
attribute among all three tables used (Master, Batting, Pitcing), and yearID
between Batting and Pitching.

Thanks again.

Chuck
 
T

Tom Wickerath

Hi Chuck,

No need to explain. I kind of deserved it.

I downloaded version 5.3 of this database and experimented with it. I also
got the overflow message any time I attempted to add a criteria to the
calculated field:

AVE Batting: (Batting.H)/(Batting.AB)

I found an older KB (Knowledge Base) article written for Access 97 that
provides a solution:
ACC97: Overflow or #Div/0! Error Occurs When You Run a Query, Form, or Report
http://support.microsoft.com/?id=301672

They use a conditional IF (IIF) statement:
=IIF([Divisor Field]=0,0,[Field A]/[Divisor Field])

but, they are not showing the use of a criteria on the [Divisor Field] to
filter out zero values. While using IIF in a query can cause it to slow down,
this appears to work for your query.

Create a new query. Dismiss the add table dialog without adding any tables.
In query design view, click on View > SQL View. You should see the word
SELECT highlighted. Copy the SQL (Structured Query Language) statement shown
below, and paste it into the SQL window, replacing the existing SELECT that
is highlighted. You can then return to normal query design view if you want,
by clicking on View > Design View.

SELECT Master.playerID, Batting.yearID, Batting.teamID,
Batting.AB, Batting.H, Pitching.W,
Format(IIf(Batting.AB=0,0,Batting.H/Batting.AB),"0.000") AS [AVE Batting]
FROM (Master INNER JOIN Batting ON Master.playerID = Batting.playerID)
INNER JOIN Pitching ON Master.playerID = Pitching.playerID
WHERE (((Batting.AB)<>0) AND ((Pitching.W)>20) AND
((Format(IIf([Batting].[AB]=0,0,[Batting].[H]/[Batting].[AB]),"0.000"))>=0.3))
ORDER BY Master.playerID, Batting.yearID;



Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

Chuck Hildebrandt said:
Tom:

Thank you very much. Your response is very refreshing and unusual for
Usenet, which at times can devolve into little better a schoolyard fight. I
apologize for my own strong reaction -- I guess it just hit me a certain way
this time. Not an excuse, just an explanation.

On the actual issue at hand, the "overflow" issue -- it was half helpful. I
was able to run the query successfully and to sort the resulting table by
batting average, but I was not able to add a filtering criterion to a
calculated field prior to running the query.

I used the Lahman 5.3 table from www.baseball1.com. Here are the actual
attributes I used:

Master.playerID
Batting.yearID
Batting.teamID
Batting.AB: <>0
Batting.H
Piching.W: >=20
AVE: Batting.[H]/[AB]

I ran this query and it executed successfully.

But when I tried to filter the AVE attribute to return only those records of
pitchers who also bating over .300 while winning 20 games, in this way:

Master.playerID
Batting.yearID
Batting.teamID
Batting.AB: <>0
Batting.H
Piching.W: >=20
AVE: Batting.[H]/[AB]: >=0.3

I got the Overflow message again.

What's the difference here? By the way, I interrelated the playerID
attribute among all three tables used (Master, Batting, Pitcing), and yearID
between Batting and Pitching.

Thanks again.

Chuck
 
Top