December 6, 2011 at 6:51 pm
I have to create a table where there are lots of columns pulling date from one table and two views. To display the columns is no problem. The problem comes into play when I have to alias two columns to show a patient who received services from the first two distinct doctors (doctor_1 and doctor_2). Each doctor has their own ID. I’m not sure if I should use the “distinct top (2)”, “rank”, etc… Here is what it sort of looks like.
Date, LastName, FirstName, Address, City, State, Zip, Hostital, Room, Doctor_1,Doctor_2
Any help would be greatly appreciated.
December 9, 2011 at 3:55 am
Hi,
One way is "Top 2" of doctors in a subquery and link it to patient table to get your data extract.
regards
Natraj
December 9, 2011 at 4:04 am
Can you confirm that you are using SQL Server 2000?
Have a quick read of the link "here" in my sig, it will help you frame your question for a better answer.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply