title: Oracle SQL - Select Max Integer Value from UserID String
body: <p>I want to select the <code>MAX</code> value of the integer associated with the UserID in my Oracle database table to generate the next username for users with similar UserID.</p>
  
  <p>The UserID contains values such as below. There is no fixed pattern of characters before the integer as the string is a username.</p>
  
  <pre><code>TKe10
  TKe9
  TKe12
  TomKelly13
  TomKelly9
  PJames12
  PJames7
  </code></pre>
  
  <p>I tried using the query below but it always gives <code>TKe9</code> OR <code>TomKelly9</code> OR <code>PJames7</code> as the <code>MAX</code> value.</p>
  
  <pre><code>SELECT * FROM 
                (SELECT MAX(UserID) from PV_USERS
                WHERE REGEXP_LIKE (UserID, '^'|| '&lt;some_user_id&gt;'|| '[^A- 
                Za-z][0-9]*'));
  </code></pre>
  
  <p>I have also tried using <code>ORDER BY DESC WHERE ROWNUM&lt;=1</code> but it also gives the same output.</p>