title: In SQL, how do I select * from a table, but when multiple rows have the same field, select only the ones where another field B is MAX?
body: <p>For example, I have a Table</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Id</th>
  <th>CarPartId</th>
  <th>CarPartPrice</th>
  <th>Metadata</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>spanner</td>
  <td>580</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>2</td>
  <td>spanner</td>
  <td>570</td>
  <td>Some other data 2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>wheel</td>
  <td>423</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>4</td>
  <td>window</td>
  <td>234</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>5</td>
  <td>engine</td>
  <td>568</td>
  <td>Some other data 1</td>
  </tr>
  <tr>
  <td>6</td>
  <td>engine</td>
  <td>423</td>
  <td>Some other data 2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Notice that when I do a SELCT * FROM this table, I would get two rows of CarPartId, but what I really want is to get the CarPartId row whereby the CarPartPrice is the highest, along with other rows from the table.</p>
  <p>How do I achieve this? For example, my query should return this</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Id</th>
  <th>CarPartId</th>
  <th>CarPartPrice</th>
  <th>Metadata</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>spanner</td>
  <td>580</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>3</td>
  <td>wheel</td>
  <td>423</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>4</td>
  <td>window</td>
  <td>234</td>
  <td>Some other data</td>
  </tr>
  <tr>
  <td>5</td>
  <td>engine</td>
  <td>568</td>
  <td>Some other data 1</td>
  </tr>
  </tbody>
  </table>
  </div>