title: Group by select based on OR condition
body: <p>After using UNION with two select queries, I'm getting following results</p>
  
  <pre><code>UserId    Name    Status
  ------   ------  --------
  1   User1   Active
  2   User2   Active
  1   User1   InActive
  3   User3   InActive
  </code></pre>
  
  <p>But the expected results is</p>
  
  <pre><code>UserId Name Status
  ---------------------
  1   User1   Active
  2   User2   Active
  3   User3   InActive
  </code></pre>
  
  <p>Here what I need is, I want to group by column Id and get status as Active if any one result is active. How to form a SQL query for this? </p>
  
  <p>Can anyone suggest query for any one of the following DB?</p>
  
  <ol>
  <li>MSSQL</li>
  <li>Oracle</li>
  <li>MySQL</li>
  <li>PostgreSQL</li>
  </ol>
  
  <p><strong>Edit:</strong></p>
  
  <p>This is the query I've tried in PostgreSQL</p>
  
  <pre><code>(SELECT DISTINCT User.Id,User.DisplayName,AppAccessToUsers.IsActive='1' AND User.IsActive='1' AS IsStatusActive 
  FROM Applications Left JOIN AppAccessToUsers ON (Applications.Id=AppAccessToUsers.ApplicationId) 
  Left JOIN User ON (AppAccessToUsers.UserId=User.Id) WHERE Applications.ClientId='e7e66c1b-b3b8-4ffb-844b-fc4840803265') 
  UNION 
  (SELECT DISTINCT User.Id,User.DisplayName,AppAccessToGroups.IsActive='1' AND Group.IsActive='1' AND UserGroup.IsActive='1' AND User.IsActive='1' AS IsStatusActive 
  FROM Applications Left JOIN AppAccessToGroups ON (Applications.Id=AppAccessToGroups.ApplicationId) 
  Left JOIN Group ON (AppAccessToGroups.GroupId=Group.Id) Left JOIN UserGroup ON (Group.Id=UserGroup.GroupId) 
  Left JOIN User ON (UserGroup.UserId=User.Id) WHERE Applications.ClientId='e7e66c1b-b3b8-4ffb-844b-fc4840803265')
  </code></pre>