Top 15

M

Mark

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
 
J

John Spencer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Weigh tasks 0
Top 3 per group 3
Using the TOP argument 1
Select Top Query 2
Crate Table Query - Closest to the 15th day..... 0
query to get top player 8
Graph usage for times of day 0
Unmatched query help 1

Top