There is the following table called Table A. (Actual data is about 200,000)
The final landing point is to leave one department number for each department and delete the duplicated data.
You can get the list of Department Nos with the following SQL. (About 300)
select DepartmentNo from TableA group by DepartmentNo having count (*)>1
With reference to this, I created the following SQL to delete the data other than the acquired data.
delete from TableA where (Department) not in ( select DepartmentNo from TableA group by DepartmentNo having count (*)>1 )
However, when the above SQL is executed, the number of data I want to keep is
It is less than when the list was acquired (about 30), and the target number cannot be DELETEd.
I don't understand why it doesn't work.
If anyone knows the cause, please let me know.
Site used as a reference site
Answer # 1
Refer to Oracle I want to delete the same key to make it unique.
The table definition should be able to be presented in CREATE TABLE.
- windows - i want to delete only when the specified path is set for the target network drive
- TextView URL and other specified special strings and click event parsing
- Detailed js delete the specified element in the array
- jQuery get objects other than a specified object (: not () and not ())
- Common methods of PHP to delete the elements of the specified value in the array instance analysis [4 methods]
- Java method to delete the specified format file in the specified directory
- Python delete consecutive occurrences of specified characters
- Python delete file instances before specified time interval
- JS click to dynamically add tags, delete code for specified tags
- PHP delete element of specified index in array method
- Example of using inode to delete a specified file under Linux
- Detailed explanation of pandas delete specified line
- Oracle EBS Tool Options: Turn off other form modification methods
- Oracle delete datagram ORA 02292 error clever solution
- vuejs delete specified item of dynamically bound radio
- How to overwrite or delete file contents in a specified location using C ++
- Android delete the app code for the specified package name
- Php delete example of the specified folder
- C ++ how to delete the element of the specified value in the map container
- sql : Time format in Oracle
- sql : How to get from the connected table only one last entry in each group?
- sql : What is the basic idea of the Logging /Nologing option when creating bd objects?
- sql : How to calculate for recording count months from the moment of inserting to a given date?
- How to create a recursive query SQL Oracle?
- sql : Reducing table size without deleting data
- mysql : How to withdraw the number of people in each SQL Department
- How to transfer several parameters through the string permanent substitution in SQL SCC
- sql : How to duplicate a string in the table and return the ID of the new line?
- As in the usual SQL script, using only SELECT statement, causing a variable to use it in a sample