title: Case statement in Oracle for selecting single row
body: <p>I have a table 'tblA' with the following data:</p>
  
  <pre><code>wuser_id wcompleted wstatusdate
  123      1          10212014
  123      0          11212014
  456      0          02222014
  456      0          03122014
  </code></pre>
  
  <p>I want to select wstatusdate for wuser_id '123' based on wcompleted, when wcompleted is 1 then I need to select '10212014' only, 
  for '456' when wcompleted is 0 then I need to select '03122014' only. My below query is returning two rows for the user_is 123.</p>
  
  <p>Below is what I am doing,</p>
  
  <pre><code>select distinct wuser_id,
  case wcompleted 
  when 1
  then max(wstatusdate)
  when 0
  then max(wstatusdate) 
  end  
  from tblA 
  group by wuser_id, wcompleted
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>wuser_id wstatusdate
  123      10212014
  123      11212014
  456      03122014
  </code></pre>
  
  <p>I need the result to be:</p>
  
  <pre><code>wuser_id wstatusdate
  123      10212014
  456      03122014
  </code></pre>