Get n records grouped by a certain field

From: Sashi <smalladi_at_gmail.com>
Date: Fri, 11 Dec 2009 07:25:42 -0800 (PST)
Message-ID: <cebfa68f-0a23-4820-bfd0-45579ba689a7_at_p8g2000yqb.googlegroups.com>



Hi all,

Let's say I have the canonical employee table. Let's say I have a dept_id field.
Let's say that there are 1000+ employees in each department.

Can it be done via sql that I need to see, say 10 employees from each department?

select emp_last_name, dept_id
from employee
(but only fetch 10 employees for each department and I do want all departments selected).

Hope that makes sense.

TIA,
Sashi Received on Fri Dec 11 2009 - 09:25:42 CST

Original text of this message