A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Top 15



 
 
Thread Tools Display Modes
  #1  
Old July 28th, 2006, 01:31 PM posted to microsoft.public.access.queries
Mark
external usenet poster
 
Posts: 1,534
Default Top 15

Hello all,

I have a top 15 query that works fine except I would like to get the top 15
per day.

So if I have 3 dates it would show each date with 15 in the list.

How do I get it give me the top 15 of each day?

SELECT TOP 15 rDate, code, MESSAGE, Sum(duration) AS SumOfduration
FROM tbShiftHld
GROUP BY rDate, code, MESSAGE
ORDER BY Sum(duration) DESC

  #2  
Old July 28th, 2006, 01:55 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Top 15

Not sure this will work, but try

SELECT rDate, code, MESSAGE, Sum(duration) AS SumOfduration
FROM tbShiftHld
GROUP BY rDate, code, MESSAGE

HAVING Sum(Duration) in (
SELECT TOP15 Sum(duration)
FROM tbShiftHld as Tmp
WHERE Tmp.RDate = tbShiftHld.rDate
GROUP BY rDate, code, MESSAGE
ORDER BY Sum(duration) DESC)

ORDER BY rDate, Sum(duration) DESC


"Mark" wrote in message
...
Hello all,

I have a top 15 query that works fine except I would like to get the top
15
per day.

So if I have 3 dates it would show each date with 15 in the list.

How do I get it give me the top 15 of each day?

SELECT TOP 15 rDate, code, MESSAGE, Sum(duration) AS SumOfduration
FROM tbShiftHld
GROUP BY rDate, code, MESSAGE
ORDER BY Sum(duration) DESC



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.