0

I have the below query, it returns the column UP that contents duplicated values (for example '111' exists 5 times but not all of them have a value in CODE_DEPT)

select  UP, CODE_DEPT from ESP_ENSEIGNANT;

UP    CODE_DEPT
111     f
555
111
222     y
222
111
444
666
222
444     k
111     f
111     
666     x

so i want to update my query to get a unique UP with CODE_DEPT (if CODE_DEPT is not empty it returns else it returns empty)

UP    CODE_DEPT
111     f
555
222     y
444     k
666     x

1 Answer 1

1

You can use aggregation:

select up, max(code_dept) as code_dept
from ESP_ENSEIGNANT ee
group by up;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.