I want to select the rows with unique "created_by" column and picking the row with minimum "distance". Here is my table data:
id title created_by last_used distance
668 Lorem Ipsum 1 981 2012-00-00 00:00:00 12
2 Lorem Ipsum 2 981 2012-00-00 00:00:00 20
710 Lorem Ipsum 3 120 2013-01-01 00:00:00 1
769 Lorem Ipsum 4 981 2012-00-00 00:00:00 4
So, I would like to get the following rows:
id title created_by last_used distance
710 Lorem Ipsum 3 120 2013-01-01 00:00:00 1
769 Lorem Ipsum 4 981 2012-00-00 00:00:00 4
How can I achieve this with a SELECT statement?