Help with Top Values please

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi All

I need to turn the following into a queries where I get the top 'x' values
for each Officer based on their hours, not the top values for the whole
dataset. Can anyone help please.

Regards.
Bill

SELECT [Egt activity report2].Officer, [Egt activity report2].Activity, [Egt
activity report2].Hours
FROM [Egt activity report2]
GROUP BY [Egt activity report2].Officer, [Egt activity report2].Activity,
[Egt activity report2].Hours
ORDER BY [Egt activity report2].Officer, [Egt activity report2].Hours DESC;
 
Brilliant, took a bit of work as my SQL is poor to say the least but all is
now working.
Thanks.
Bill.

Allen Browne said:
See:
Subquery basics: TOP n records per group
at:
http://allenbrowne.com/subquery-01.html#TopN

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
Hi All

I need to turn the following into a queries where I get the top 'x'
values for each Officer based on their hours, not the top values for the
whole dataset. Can anyone help please.

Regards.
Bill

SELECT [Egt activity report2].Officer, [Egt activity report2].Activity,
[Egt activity report2].Hours
FROM [Egt activity report2]
GROUP BY [Egt activity report2].Officer, [Egt activity report2].Activity,
[Egt activity report2].Hours
ORDER BY [Egt activity report2].Officer, [Egt activity report2].Hours
DESC;
 
Back
Top