Good morning, I created a simple database in SQLSERVER, which has repeated employees of different ages, plus an abbreviation to see if I was single or married. What I want is for me to show the maximum age per employee, I know it is not correct, but I only did it out of curiosity, since I had not had that consultation before.
The query used is:
SELECT nom_emp,MAX(edad_emp) 'Edad',(CASE estado_civi
WHEN 'C' THEN 'Casado'
ELSE 'Soltero'
END
) 'Estado Civil'
FROM empleado a
GROUP BY nom_emp,estado_civi
As you can see, it forces me to group by marital status, which means that the record of the employee with the highest age does not necessarily appear but can be repeated.
Please, if you could answer this question, thank you very much.