Oracle queries data, where only one of the specified fields is repeated (Tutorial), the oracle Field
Oracle Database, scenario: The data in the table (customer-Clerk) is not completely duplicated, but some fields in multiple data records may be duplicated. I want to obtain qualified records in the table, but the customer id and customer name in these records must be unique.
If I want to find out all the customers that "Feng Dongmei" is responsible for, but because she belongs to multiple departments, this table stores different departments-different customers corresponding to different personnel, so there will be duplicate data, so what should I do if I want to remove duplicates and get a complete record?
I tried distinct myself, but distinct can only expose repeated fields, so there is no way to complete the record; it is not implemented by using group by. Multi-party search, the contribution of SQL is as follows:
Select s. * from
(Select t. *, row_number () over (partition by customid order by customid) as group_idx
From base_custom_to_saler t where t. salername like '% Feng Dongmei %' and t. entryid = 9) s
Where s. group_idx = 1
Row_number ()... over (partition by... order ...) The logic is to group, sort, and retrieve data for fields that meet certain characteristics.
The result is as follows: