Reputation: 1
I want to select rows which have 10 different soru_id from end of the table. It has to return only red marked rows. Table structure and red marked rows are in picture below. How can i do it?
http://i47.tinypic.com/2132iir.jpg
Upvotes: 0
Views: 67
Reputation: 82903
Assuming the soru_id decides the beginning/end of the table
Try this:
SELECT DISTINCT soru_id
FROM <YOUR_TABLE>
ORDER BY date_created DESC
LIMIT 10;
In case you need the full row instead of soru_id alone. then try this:
SELECT *
FROM <YOUR_TABLE> a
JOIN
( SELECT soru_id,
MAX(date_created) date_created
FROM <YOUR_TABLE>
GROUP BY soru_id LIMIT 10) b ON a.soru_id = b.soru_id
AND a.creation_date = b.creation_date
Upvotes: 1