Re: Top 5 Query Problem
From: Paul (P_Acker_at_NO.Hotmail.SPAM.com)
Date: 04/08/04
- Next message: MGFoster: "Re: => Query to copy tbl1 split entries into tbl2"
- Previous message: MGFoster: "Re: Sintax error"
- In reply to: Gerald Stanley: "Re: Top 5 Query Problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 14:06:14 -0400
Thanks, it helped a lot.
"Gerald Stanley" <gcstanley@dsl.pipex.com> wrote in message
news:157d101c41d72$9cfbee50$a001280a@phx.gbl...
> The feature of your requirement is that you want the top 5
> rows from the set of data from one season added with the
> top 5 rows from the set of data for another season and so
> on. I think that there are two ways of approaching this.
> If the number of seasons is quite small, then you can build
> the result with a Union query
> e.g.
>
> SELECT TOP 5 etc
> etc
> WHERE [Season Table].[Season Id] = 2003
> UNION
> SELECT TOP 5 etc
> etc
> WHERE [Season Table].[Season Id] = 2004
>
> Alternatively you could create a new table to hold these
> results. Presumably there comes a time when the season's
> averages can no longer be changed so you could populate the
> new table with the past seasons data then delete the 5 rows
> and re-add the 5 rows for the current season. Then you
> would just have to select all from the new table to get the
> results set you require.
>
> Hope This Helps
> Gerald Stanley MCSD
> >-----Original Message-----
> >Here is what Access generated for the SQL.
> >
> >SELECT TOP 5 [Season Table].[Season ID], [Batting
> Table].Batter,
> >Count([Batting
> >
> >Table].Batter) AS CountOfBatter
> >
> >FROM ([Season Table] INNER JOIN [Games Table] ON [Season
> Table].[Season ID]
> >= [Games Table].[Season
> >
> >ID]) INNER JOIN [Batting Table] ON [Games Table].[Game ID]
> = [Batting
> >Table].[Game ID] GROUP BY [Season Table].[Season ID], [Batting
> >Table].Batter, [Games Table].[Season ID], [Games
> Table].Playoff, [Batting
> >Table].[1 2 3 H] HAVING ((([Games Table].[Season
> ID])=[Season Table.Season
> >ID]) AND (([Games Table].Playoff)=False) AND (([Batting
> Table].[1 2 3
> >H])="4")) ORDER BY [Season Table].[Season ID] DESC ,
> Count([Batting
> >Table].Batter) DESC;
> >
> >"Gerald Stanley" <gcstanley@dsl.pipex.com> wrote in message
> >news:1997401c41ccb$0f23a6b0$a301280a@phx.gbl...
> >> Can you post the SQL that gives the correct counts
> >>
> >> Gerald Stanley MCSD
> >> >-----Original Message-----
> >> >I'm trying to make a query of the Top 5 that will
> >> eventually be displayed on
> >> >a form. What I have is a db tracking the company softball
> >> team. I would
> >> >like this query to count the number of homers a player has
> >> hit and give me
> >> >the total, which I have seem to be able to do. All the
> >> counts are correct.
> >> >The problem I'm having is I'd like it to show the Top 5,
> >> for each year. I'm
> >> >getting data back that shows 5 records, but it shows them
> >> as one record from
> >> >this year and only four from last. How do I get the query
> >> to the Top 5 of
> >> >each season?
> >> >
> >> >Thanks in advance
> >> >
> >> >Paul
> >> >
> >> >
> >> >.
> >> >
> >
> >
> >.
> >
- Next message: MGFoster: "Re: => Query to copy tbl1 split entries into tbl2"
- Previous message: MGFoster: "Re: Sintax error"
- In reply to: Gerald Stanley: "Re: Top 5 Query Problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|