I have a table like this :
course (id not unique) | coursemodule (nvarchar) | time_added (timestamp)
The table register every coursemodule (consider it a child of course) added with a log of the time it was added
So I want to get the oldest coursemodule created for every courses
Something like
SELECT course, coursemodule, min(time_added)
FROM my_table
GROUP BY course;
But we can do a group by with a nonaggregated column
I also have seen
SELECT t.course, t.coursemodule, t.time_added
FROM my_table t
WHERE time_added=(SELECT MIN(t2.time_added)
FROM my_table t2
WHERE t.course = t2.course);
But the subquery return more than one row so it's not usable...