I have a table in mysql where i need to display the columns Uid, CreatedDate and Action_key and Value, grouping by action key.
Table: UsersOptStatus
Expected result:
I need to order by desc CreatedDate and show the latest Action_keys
Below is what i tried - This gives me all the Action_keys, but i need to show latest Action_keys based on last (ie Desc) Created_date:
SELECT uid,
action_key,
value,
Max(createddate) CreatedDate
FROM usersoptstatus
WHERE uid = 1607
GROUP BY action_key,
value;
Even the below query not gives me Expected Result,
SELECT uid,
value,
action_key
FROM (SELECT uid,
Max(createddate) CreatedDate
FROM usersoptstatus
GROUP BY uid) A
INNER JOIN usersoptstatus USING (uid, createddate)
WHERE uid = 1607
ORDER BY id DESC;



