title: PostgreSQL: Add condition in where clause using CASE
body: <p>I am using PostgreSQL 8.2 and I am also new to PostgreSQL. </p>
  
  <p>I have to add one condition in the WHERE clause depending upon specific value (49) of the field (<strong>activity.type</strong>). Here is my Query:</p>
  
  <pre><code>SELECT activity.*
  FROM activity 
  LEFT JOIN event_types ON activity.customstatusid = event_types.id, getviewableemployees(3222, NULL) AS report 
  WHERE 
  ( 
      CASE WHEN activity.type = 49 THEN 
      'activity.individualid IN(SELECT individualid from prospects where prospects.individualid = activity.individualid)' 
      ELSE 1 
      END 
  )
  AND activity.date BETWEEN '2016-10-01' AND '2016-10-06' 
  AND activity.type IN (21, 22, 49, 50, 37, 199) 
  AND (event_types.status = 1 or event_types.status IS NULL);
  </code></pre>
  
  <p>When I run above query in the command line access of PGSQL then I get below error:</p>
  
  <pre><code>ERROR:  invalid input syntax for integer: "activity.individualid IN(SELECT individualid from prospects where prospects.individualid = activity.individualid)"
  </code></pre>
  
  <p>What I am missing here?</p>