Can ChatGPT Write good SQL?
I asked ChatGPT: write sql to delete duplicate records in Oracle database table called employee, for duplicate employee_id
ChatGPT: To delete duplicate records in Oracle database table called employee for duplicate employee_id, you can use the following SQL query:
DELETE FROM employee?
WHERE ROWID NOT IN?
(
?SELECT MAX(ROWID)?
?FROM employee?
?GROUP BY employee_id
);
Explanation:
This query will delete all the duplicate records in the employee table for each employee_id, and keep only the record with the highest ROWID.