lundi 1 décembre 2014

SQL Access GROUP BY et ID


Vote count:

0




I found out some examples but I have difficulties applying this to my case and as I need the query very quickly, I am coming to you SQL masters :)


I need the below SELECT to return Sessions.id (the one that corresponds to Max(Sessions.DateFin) for each row)


SELECT Sessions.idFormation, Inscriptions.idPersonnel, Max(Sessions.DateFin) AS Dernier FROM Sessions INNER JOIN Inscriptions ON Sessions.id = Inscriptions.idSession GROUP BY Sessions.idFormation, Inscriptions.idPersonnel


I believe I need to use something like SELECT * FROM Table1 t1 JOIN ( SELECT category, MAX(date) AS MAXDATE FROM Table1 GROUP BY category ) t2 ON T1.category = t2.category AND t1.date = t2.MAXDATE


but as t1 in my case is already a query I do not get how to implement this solution.



asked 29 secs ago







SQL Access GROUP BY et ID

Aucun commentaire:

Enregistrer un commentaire