title: Joins and condition
body: <p>I need to get the activity name where deletedsw='0' and eventdtm=sysdate-12. But inorder to get the activity full name it is doing the self join I think. But I am not sure how to include these condition in those query. Can anyone please help</p>
  
  <pre><code>SELECT  
    (DECODE(levelLess3.activitynm, NULL, '', levelLess3.activitynm || '/') ) || 
   (DECODE(levelLess2.activitynm, NULL, '', levelLess2.activitynm || '/') ) || 
   (DECODE(levelLess1.activitynm, NULL, '', levelLess1.activitynm || '/') ) || 
     wa.activitynm as ACTIVITYFULLNM
    FROM wfaactivity wa
      LEFT OUTER JOIN WFAACTIVITY levelless1 ON (wa.parentid = levelless1.wfaactivityid
     AND levelless1.wfaactivityid != wa.wfaactivityid)
   LEFT OUTER JOIN WFAACTIVITY levelless2 ON (levelless1.parentid = levelless2.wfaactivityid
     AND levelless2.wfaactivityid != levelless1.wfaactivityid)
   LEFT OUTER JOIN WFAACTIVITY levelless3 ON (levelless2.parentid = levelless3.wfaactivityid
     AND levelless3.wfaactivityid != levelless2.wfaactivityid)
  </code></pre>
  
  <p>I want to include the condition like</p>
  
  <pre><code>where wa.wfaactivityid=wspan.wfaactivityid
  and wspan.deletedsw='0'
  and to_char(wspan.eventdtm, 'yyyymmdd') &gt;= to_char(sysdate-12,'yyyymmdd')
  </code></pre>
  
  <p>wspan is another table from where we are taking deletedsw and eventdtm</p>
  
  <p>yeah I gave like this</p>
  
  <pre><code>SELECT  
    (DECODE(levelLess3.activitynm, NULL, '', levelLess3.activitynm || '/') ) || 
   (DECODE(levelLess2.activitynm, NULL, '', levelLess2.activitynm || '/') ) || 
   (DECODE(levelLess1.activitynm, NULL, '', levelLess1.activitynm || '/') ) || 
     wa.activitynm as ACTIVITYFULLNM
    FROM wfaactivity wa,WFAREPACTYSPAN wspan
    where
    wa.wfaactivityid=wspan.wfaactivityid
  and wspan.deletedsw='0'
  and to_char(wspan.eventdtm, 'yyyymmdd') &gt;= to_char(sysdate-12,'yyyymmdd')
  and
      LEFT OUTER JOIN WFAACTIVITY levelless1 ON (wa.parentid = levelless1.wfaactivityid
     AND levelless1.wfaactivityid != wa.wfaactivityid)
   LEFT OUTER JOIN WFAACTIVITY levelless2 ON (levelless1.parentid = levelless2.wfaactivityid
     AND levelless2.wfaactivityid != levelless1.wfaactivityid)
   LEFT OUTER JOIN WFAACTIVITY levelless3 ON (levelless2.parentid = levelless3.wfaactivityid
     AND levelless3.wfaactivityid != levelless2.wfaactivityid)
  </code></pre>
  
  <p>But I am getting the error ORA-00920 Invalid relational operator</p>