I have a table with columns like id
, mail
, hits
, time
.
I want to get the 10 entries with the lowest hits
and time
values (best entries).
I used something like this:
SELECT *
FROM tablename
ORDER BY hits, time ASC
In my table, there are many entries with the same mail
addresses but I only want 10 entries with different mail addresses. So I tried the group by
statement after which the data is mixed up.
How can I select the 10 best entries (lowest hits
and time
) with different mail
addresses ?
This query I have not been test because there is no SQL-Fiddle example or a code to replicate your data.
But give this wild query a try.
Here is explanation of the query: