Puoi usare l'aggregazione: select up, max(code_dept) as code_dept from ESP_ENSEIGNANT ee group by up;