title: How to select only distinct row when there might be duplicates using SQL?
body: <p>I have a tricky SQL query I could use some help with.</p>
  
  <p>I have a phone directory table, that was not designed very well.  It has name, phone number, job description and primary_job_indicator.  However, the primary_job_indicator isn't doing it's job.  Not everyone has a primary_job.</p>
  
  <p>Here's some sample data:</p>
  
  <pre><code>  fname     lname     phone     email           job          primary_job_ind
    Tim       Burton    222-2222  tburton@ok.com  manager      Y
    Jim       Classy    222-3333  tclassy@ok.com  instructor   Y
    Jim       Classy    222-3333  tclassy@ok.com  dept head    N
    Jane      Dill      222-4444  jdill@ok.com    janitor      N
  </code></pre>
  
  <p>I would like to select only the following, one row, with one job per person :</p>
  
  <pre><code>  Tim Burton    222-2222  tburton@ok.com  manager
    Jim classy    222-3333  jclassy@ok.com  instructor
    Jane Dill     222-4444  jdill@ok.com    janitor
  </code></pre>
  
  <p>I want to select from the table and avoid duplicate name+phone number+email.  </p>
  
  <p>If the person has only one row in the table, I want to select that row.</p>
  
  <p>If the person has more than one row in the table, I want to select only one row - the one with primary_job_ind = 'Y' if it exists</p>
  
  <p>I can't figure out how to do it : </p>
  
  <pre><code>SELECT fname, lname, phone, email, job
  FROM phonedirectory
  WHERE  (( primary_job_ind = 'Y' ) OR ??????? ) 
  </code></pre>