I have a table with records and I want to delete all duplicate records name, age, date are columns I am getting from a file.
CREATE_DATE
is the column that captures when I loaded the file.file_id
is from the id I am generating based on thefile_log_sys
tablestage_id
is an identity column
Sample data:
stage_id name age date file_id create_date
---------------------------------------------------------
1 john 25 2019-02-02 100 2019-04-04
2 sam 50 2019-01-13 100 2019-04-04
3 john 25 2019-02-02 101 2019-04-05
4 peter 33 2019-01-01 101 2019-04-05
I would like to delete the record where file_id = 100 and stage_id = 1 and name= john
I tried:
delete min(file) id
from table
and it didn't work.
I want my output to be
stage_id name age date file_id create_date
-----------------------------------------------------------
2 sam 50 2019-01-13 100 2019-04-04
3 john 25 2019-02-02 101 2019-04-05
4 peter 33 2019-01-01 101 2019-04-05
Can you please help me with the query?
Thanks in advance.