title: Is there a way to find TOP X records with grouped data?
body: <p>I'm working with a Sybase 12.5 server and I have a table defined as such:</p>
  
  <pre><code>CREATE TABLE SomeTable(
      [GroupID] [int] NOT NULL,
      [DateStamp] [datetime] NOT NULL,
      [SomeName] varchar(100),
      PRIMARY KEY CLUSTERED (GroupID,DateStamp)
  )
  </code></pre>
  
  <p>I want to be able to list, per [GroupID], only the latest X records by [DateStamp].  The kicker is X > 1, so plain old MAX() won't cut it.  I'm assuming there's a wonderfully nasty way to do this with cursors and what-not, but I'm wondering if there is a simpler way without that stuff.</p>
  
  <p>I know I'm missing something blatantly obvious and I'm gonna kick myself for not getting it, but .... I'm not getting it.  Please help.</p>
  
  <p>Is there a way to find TOP X records, but with grouped data?</p>