I have tried even simple SQL query too but I am not getting latest result in group by. I have tried these.
1)-
SELECT price_factors.*
FROM (SELECT * FROM price_factors ORDER BY id DESC) price_factors
GROUP BY price_factors.trait_id`
2)-
SELECT *
FROM price_factors
GROUP BY trait_id
ORDER BY id DESC