title: PostgreSQL conditional where clause
body: <p>In my Ruby on Rails app I'm using blazer(<a href="https://github.com/ankane/blazer" rel="noreferrer">https://github.com/ankane/blazer</a>) and I have the following sql query:</p>
  
  <pre><code>SELECT *
  FROM survey_results sr
  LEFT JOIN clients c ON c.id = sr.client_id
  WHERE sr.client_id = {client_id}
  </code></pre>
  
  <p>This query works really well. But I need to add conditional logic to check if client_id variable is present. If yes then I filter by this variable, if not then I not launching this <code>where</code> clause. How can I do it in PostgreSQL?</p>