问题
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:
You can use aggregation:
select up, max(code_dept) as code_dept
from ESP_ENSEIGNANT ee
group by up;
来源:https://stackoverflow.com/questions/65708761/sql-oracle-remove-duplicate-value