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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|