title: SQL LEFT JOIN with WHERE class
body: <p>there are two tables TABLE1 and TABLE2 in TABLE1 there are records which does not exist in TABLE2 with left join below i wanted to query all records which are in TABLE1 if the record does not exist in table2 however.</p>
  
  <p>Note: about WHERE class in my code that is required this is because, there can be several records in the name of 'IN PROGRESS' in TABLE2 with one record in the name of 'GRADUATED' i wanted to distinct records based on table 1 ID that if there is any record in the name of 'GRADUATE' it should show only that else it should show inprogress.</p>
  
  <pre><code>SELECT DISTINCT 
         TABLE1.ID, 
         TABLE2.TRAINING_STATUS_CHECK
  FROM TABLE1
  LEFT JOIN TABLE2
      ON TABLE1.ID = TABLE2.FK_ID_CLASS
  WHERE NOT EXISTS 
      (
      SELECT DISTINCT 
             TABLE1.ID, 
             TABLE2.TRAINING_STATUS_CHECK
      FROM TABLE1
      LEFT JOIN TABLE2
          ON TABLE1.ID = TABLE2.FK_ID_CLASS
      WHERE TABLE2.TRAINING_STATUS_CHECK = 'GRADUATED')
  OR TABLE2.TRAINING_STATUS_CHECK = 'GRADUATED'
  </code></pre>