SELECT MAX(Program.Name) AS Program,MAX(Something.Name) AS Something,COUNT(*) AS 'Count of projects' FROM MainTable INNER JOIN Program ON MainTable.NoProgram=Program.ID INNER JOIN Something ON MainTable.NoSomething=Something.ID INNER JOIN Project ON MainTable.ID=Projet.NoMainTable GROUP BY Program.Name,Something.NameThus, I have my repartition on the first two fields followed by the count of projects corresponding to each record.