title: MAX(DATE) - SQL ORACLE
body: <p>I want to select only the latest membership_id from table user_payments
  of the user with the user_id equal to 1.</p>
  
  <p>This is how the table user_payment looks like:</p>
  
  <pre><code>   PAYM_ID    USER_ID MEMBSHIP_ID PAYM_DATE                     
  ---------- ---------- ----------- -------------------------------
           1          1           1 18-DEC-09 12.00.00.000000000 AM 
           2          1           2 18-DEC-10 12.00.00.000000000 AM 
           3          1           2 18-DEC-11 12.00.00.000000000 AM 
           4          2           3 17-MAR-11 12.00.00.000000000 AM 
           5          3           3 18-JUN-12 12.00.00.000000000 AM 
           6          4           2 17-FEB-12 12.00.00.000000000 AM 
           7          5           2 18-FEB-11 12.00.00.000000000 AM 
           8          5           2 18-FEB-12 12.00.00.000000000 AM 
           9          6           1 01-JUN-12 12.00.00.000000000 AM 
          10          7           1 03-FEB-11 12.00.00.000000000 AM 
          11          7           2 03-FEB-12 12.00.00.000000000 AM 
  </code></pre>
  
  <p>I am trying with no success the following code:</p>
  
  <pre><code>SELECT MEMBSHIP_ID
  FROM user_payment
  WHERE user_id=1 and MAX(paym_date);
  </code></pre>
  
  <p>And I get this error:
  SQL Error: ORA-00934: group function is not allowed here
  00934. 00000 -  "group function is not allowed here"</p>
  
  <p>How can I fix it? thanks in advance!</p>