From: tfs@dslextreme.com   
      
   "Lennart Jonsson" wrote in message   
   news:i9tptv$8nu$1@news.eternal-september.org...   
   > On 2010-10-22 15:59, Roger wrote:   
   > [...]   
   >>   
   >> You could use a left join and exclude the empty rows in the where   
   >> clause...   
   >>   
   >> left JOIN EmployeeAnswerMap on EAM.AnswerID = A.AnswerID   
   >> left JOIN CustomerAnswerMap on CAM.AnswerID = A.AnswerID   
   >> where not (EAM.AnswerID is null and CAM.AnswerID is null)   
   >>   
   >> but then you will need two sets of columns for employee and customer   
   >> i.e. select c.firstname, c.lastname, e.firstname, e.lastname   
   >>   
   >   
   > You could output only one of them as in:   
   >   
   > case when c.firstname is not null then c.firstname else e.firstname end   
   > as firstname, ...   
   >   
   > or   
   >   
   > coalesce(c.firstname , e.firstname) as firstname, ...   
   >   
   That is what I would do if I don't do the UNION.   
      
   > but a union is the most natural choice here   
   >   
   I agree. Just trying to see if there is a better way with better   
   performance.   
      
   Thanks,   
      
   Tom   
      
   >   
   > /Lennart   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|