Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Patiently Waiting

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-03-13 : 10:46:28
I am trying to create a patient waiting list. My problem is that we see relatives together. What I have is a view which tells me the 'main' person waiting and another view that tells me the 'secondary' waiters i.e. the relatives that are to be seen with the main waiter. I want to join them together so that I can see relatives easily.

For example we may have in the main waiters list

Patient1,WaitingListID3,... (other patient details)
Patient2,WaitingListID7,...
Patient14,WaitingListID2

etc

In the secondary waiters view we may have

Patient12,WaitingListID3,...
Patient13,WaitingListID3,...
Patient200,WaitingListID7,...
Patient120,WaitingListID30,...

etc

What I want is to produce a list that has the main waiter followed by the related secondary waiters, using the example above we might have

Patient1,WaitingListID3,...
Patient12,WaitingListID3,...
Patient13,WaitingListID3,...
Patient2,WaitingListID7,...
Patient200,WaitingListID7,...
Patient14,WaitingListID2
Patient120,WaitingListID30,...

etc.

I get the feeling that this should be simple but I can't get my head around it. I realise I could union the two views and order by the waiting list ID (though this doesn't guarantee the 'main' waiter will be listed first) but I think this would run too slowly and was wondering if there was a neater method

Thanks in advance

steve

lee_h
Starting Member

36 Posts

Posted - 2003-03-13 : 18:10:20
if you've already created views, you could a 1 to the end of the main_waiters view and a 2 to the end of the secondary_waiters view so that you can ensure they come out in the correct order.

i.e.

create view main_waiter as
select patient, waitinglistid, 1 as sort_order
from table


create view secondary_waiters as
select patient, waitinglistid, 2 as sort_order
from table


Go to Top of Page
   

- Advertisement -