Zkuste tento dotaz
Pokud chcete pouze pro user1
pak použijte tento dotaz:
select username, course_id, max(ldate) as date
from tbl
where username='user1'
group by username, course_id
SQL FIDDLE
| USERNAME | COURSE_ID | DATE |
-------------------------------------
| user1 | 22 | 2013-06-03 |
| user1 | 54 | 2013-06-03 |
Pokud chcete najít nejnovější datum pro všechny uživatele, použijte tento dotaz
select username, course_id, max(ldate) as date
from tbl
group by username, course_id
V tomto dotazu data user2
bude také zahrnut
| USERNAME | COURSE_ID | DATE |
-------------------------------------
| user1 | 22 | 2013-06-03 |
| user1 | 54 | 2013-06-03 |
| user2 | 71 | 2013-06-04 |