title: SQL Server - Find last row that matches a specific value
body: <p>I'm new to SQL and I'm having trouble creating a query to find the last entry in a table where one column contains part of a specific string. I have a database similar to:</p>
  
  <pre><code>Part Number | Description | Qty 
  ------------+-------------+-----
     MO1      | Big Motor   | 1 
     MO2      | Small Motor | 5   
     XYZ      | Garbage     | 1 
     BO1      | Big Bolt    | 1 
     BO2      | Small Bolt  | 2 
  </code></pre>
  
  <p>I'm looking for a way to query any entry in which the "Part Number" starts with "MO" then return just the last entry ("MO2/Small Motor/5" in this case). The part numbers are always sequential, but there can be a lot of junk data in between clumps of properly formatted numbers. I'm much more used to working with Excel where I can "Find" a string by searching in reverse order, but I don't know how to do the equivalent in SQL. </p>