title: Select from multiple rows based on column value
body: <p>I've got a table with rows of info on various units. This info is sourced from two locations, A and B. Source A contains info from every unit in the table, while source B contains more accurate info but only for some of the units.</p>
  
  <p>How would I go about selecting one row for each unit, but prioritizing the selection of info from source B (when info is available) over source A, thus generating just one row for the unit with data from B? Right now if a unit is in both sources, it will come up as two different rows in my query. I've tried using a case when statement in the where clause and IF statements in the select statement.</p>
  
  <p>I feel like there's a very simple solution to this but for some reason I'm struggling to figure this out. Thanks in advance.</p>
  
  <p>Table Structure:
  UnitKey(PK)   UnitID   Hours   DataSource</p>