Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select 75 records for each field 1

Status
Not open for further replies.

scottshiv

MIS
Sep 13, 2002
47
US
I have a doctor table with doctor and patient ID's. I want to select 75 patients for each doctor whose insurance date is currently still active. How would I do that?

Doctor Table
Doctor ID
Patient ID
insurance begin date
insurance end date

 
Code:
Select DoctorID, PatientID, BeginDate, EndDate

From DoctorTable D1

Where PatientID IN

          (Select TOP 75 PatientID From DoctorTable D2
           Where D2.DoctorID = D1.DoctorID
             AND BeginDate <= Date() AND EndDate >= Date())

Order by DoctorID, PatientID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top