title: How do I get 1 row from set of multiple rows based on a condition in PostgreSQL 10?
body: <p>I have two tables, user and car with below mentioned rows and columns.</p>
  <p>Table 1: user</p>
  <pre><code>id | name
  ---------
  1  | ABC
  2  | PQR
  3  | XYZ
  </code></pre>
  <p>Table 2: car</p>
  <pre><code>id | user_id | is_serviced
  --------------------------
  1  |    1    |     0
  2  |    1    |     1
  3  |    2    |     0
  4  |    2    |     0
  </code></pre>
  <p>User ABC has two cars - only one car has been serviced.<br/>
  User PQR has two cars - none of the cars has been serviced.<br/>
  User XYZ has no cars yet.</p>
  <p>I want to fetch records as per below output where I want to display all users who have at least one serviced car.</p>
  <p>The query I have (I do not understand what clause to use for my query to get the expected output):</p>
  <pre><code>SELECT u.user_name,
         CASE WHEN c.is_serviced = true THEN 'YES' ELSE 'NO' END AS has_serviced_car
  FROM &quot;user&quot; u
           LEFT JOIN car c ON c.user_id = u.id;
  </code></pre>
  <p>The output of the above query:</p>
  <pre><code>user_name | has_serviced_car
  -----------------------
     ABC    |     No
     ABC    |     Yes
     PQR    |     No
     PQR    |     No
     XYZ    |     No
  </code></pre>
  <p>Expected output:</p>
  <pre><code>user_name | has_serviced_car
  -----------------------
     ABC    |     Yes
     PQR    |     No
     XYZ    |     No
  </code></pre>
  <p><strong>Please note that user XYZ has no cars still I need it to be displayed.</strong></p>