I want to select only the latest membership_id from table user_payments of the user with the user_id equal to 1.
This is how the table user_payment looks like:
Try:
SELECT MEMBSHIP_ID FROM user_payment WHERE user_id=1 ORDER BY paym_date = (select MAX(paym_date) from user_payment and user_id=1);
Or:
SELECT MEMBSHIP_ID FROM ( SELECT MEMBSHIP_ID, row_number() over (order by paym_date desc) rn FROM user_payment WHERE user_id=1 ) WHERE rn = 1