• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Recordset paging

Hi,

I've got a set of data, like so:

UserID  |  SongID  |  Title  |  Name
700  |  4843  |  Turn The Music Up (Sample Only)  |  John Smith 1
10020  |  58834  |  The Way  |  John Smith 3
10466  |  58972  |  against the wall  |  John Smith 5
10466  |  58975  |  settle down new  |  John Smith 5
10466  |  58973  |  senyourita  |  John Smith 5
10466  |  58976  |  too late  |  John Smith 5
745  |  4409  |  Aida (Sarah McLachlan)  |  John Smith 2
10199  |  59243  |  Hustla'-featuring Venumb  |  John Smith 4

Normally when i want to do some recordset paging, i will pass into the stored procedure the page number, and the number of records per page, and then with the use of a temp table i can return the rows i need. The problem i have with the above scenario is that when i say i want 4 records, i actually want 4 UNIQUE UserID's, but as many records as are necessarry that are related to those 4 userID's.....does that make sense.....anyone have any idea how this can be achieved???

Thanks in advance

Al
0
higgsy
Asked:
higgsy
1 Solution
 
mcmonapCommented:
Hi higgsy,

Does this do something like what you want?  you don't specifiy which four userid's you want to match...

SELECT UserID, SongID, Title, [Name]
FROM YourTable
WHERE USERID IN (SELECT DISTINCT TOP 4 UserID FROM YourTable)
0
 
JulianvaCommented:
SELECT UserID, SongID, Title, Name
FROM YourTable
WHERE USERID IN (10020,10466,745,10199 )
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now