title: How to return two values when using when exists in SQL
body: <p>In the <code>ot_notes</code> table there are different tasks for each job. This specific job has 20 rows. I need to find 'Weld_Complete', if it doesn't exist I am looking for 'Weld_Start'. This code works the way I want it too, but I also need to return the job number, so I can link it to another query. How do I do that? </p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>SELECT 
      CASE 
         WHEN EXISTS (SELECT 1 FROM ot_notes) 
            THEN (SELECT task 
                  FROM ot_notes 
                  WHERE job = '61249' AND task = 'Weld_Complete') 
         ELSE
            CASE 
               WHEN EXISTS (SELECT 1 FROM ot_notes) 
                  THEN (SELECT task 
                        FROM ot_notes 
                        WHERE job = '61249' AND task = 'Weld_Start') 
               ELSE ' ' 
            END 
      END AS weld
  </code></pre>
  
  <p>The following query gives me all tasks for job 61249: SELECT job, task from ot_notes WHere job = '61249'. This is different for each job. I need to find Weld_Complete, if it's not there, I need to look for Weld_Start, or find if neither is there. I need both he job and task fields. The above query gives me what I want, except job.   </p>
  
  <pre><code>job     task
  -----   -----------
  61249   Update_Date
  61249   Weld_Start
  61249   Paint_Start
  61249   Note
  61249   Note
  61249   Note
  61249   Ship_Complete
  61249   Update_Date
  61249   Note
  61249   Note
  61249   Note
  61249   Paint_Complete
  61249   Weld_Complete
  61249   Note
  61249   Note
  61249   Ship_Partial
  61249   Update_Date
  61249   Note
  61249   Note
  61249   Note
  </code></pre>