I want to group below data from sub_prd_id. but before that i need order data from max created_at.
sub_prd_id
created_at
I wrote query as below.
SELECT x.* FROM prd_data x JOIN ( SELECT sub_prd_id , MAX(created_at) max_created_at FROM prd_data GROUP BY sub_prd_id ) y ON y.sub_prd_id = x.sub_prd_id AND y.max_created_at = x.created_at;