SELECT COALESCE (rsu.last_name + ', ' + rsu.first_name + ' ' + rsu.middle_name + '.', rsu.last_name + ', ' + rsu.first_name) as student_name, rsu.day_id
FROM roster_school_unattended rsu
GROUP BY student_name
ORDER BY rsu.day_id
does not work. What’s the most elegant workaround?
EDIT: The result-set should have something like this
Muster, Hans | 2011-11-01
Muster, Hans | 2011-11-02
Williams, Clay | 2011-10-01
Williams, Clay | 2011-10-02
First the name is grouped by, then for each name there is a sorting of dates.
EDIT: Whole thing replaced as the recent edit to the question shows that GROUP BY isn’t needed…
Without any changes for ‘elegance’…
Possible change for ‘elegance’…
Another possible using APPLY…