[AccessD] Totals Query: Top Predicate

Admin Sparky dba.email at gmail.com
Mon Feb 7 13:27:18 CST 2005


Here is SQL:

SELECT TOP 5 [qry1].InputYear, 
                       [qry1].InputMonth, 
                       [qry1].fkChecklistItem,
                       Sum([qry1].Errors) AS SumOfErrors,
                       [qry1].ByMonthYear,
                       [qry1].[CODE DESCRIPTION]
FROM              [qry1]
GROUP BY      [qry1].InputYear,
                      [qry1].InputMonth,
                      [qry1].fkChecklistItem,
                      [qry1].ByMonthYear,
                      [qry1].[CODE DESCRIPTION]
ORDER BY      [qry1].InputYear,
                      [qry1].InputMonth,
                      Sum([qry1].Errors) DESC;


Mark



On Mon, 7 Feb 2005 14:13:12 -0500, Admin Sparky <dba.email at gmail.com> wrote:
> That is what I have now.  Totals sorted in descending order...
> 
> Mark Mitsules
> 
> 
> On Mon, 7 Feb 2005 13:54:36 -0500, Mike & Doris Manning
> <mikedorism at adelphia.net> wrote:
> > Sort the total value in descending order and take top 5.
> >
> > Doris Manning
> > Database Administrator
> > Hargrove Inc.
> > www.hargroveinc.com
> >
> >
> > -----Original Message-----
> > From: accessd-bounces at databaseadvisors.com
> > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Admin Sparky
> > Sent: Monday, February 07, 2005 1:47 PM
> > To: accessd at databaseadvisors.com
> > Subject: [AccessD] Totals Query: Top Predicate
> >
> > Group,
> >
> > I have a totals query grouped by year, then month.  I would like to return
> > the top 5 records for each year/month combination.  What are my options?  At
> > the moment, the top predicate merely returns the top 5 records for the first
> > year/month combination.
> >
> > Mark Mitsules
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>



More information about the AccessD mailing list