title: Postgresql selecting specific set of records based on a field value
body: <p>I have postgresql data-set as shown below where a app_id may have multiple record. I need to select all the records for each app_id where bool_flag is true and if a app_id has no records with bool_flag value equal true then pick all records with false value for that app. </p>
  
  <p>Here is the link to available data set
  <a href="https://i.stack.imgur.com/0XTfF.png" rel="nofollow noreferrer">data-set</a></p>
  
  <p>and this is the desired output I am looking for, thanks in advance.
  <a href="https://i.stack.imgur.com/UTPxN.png" rel="nofollow noreferrer">desired output</a></p>