So I'm trying (actually made it work in MySql) to grab 3 columns from the source table, remove its duplicates just based on 2 of those 3 columns (that's why I need the partition and row_number), and once duplicates are dropped, I'm checking into the target table if those same 2 values are not already existing.
But now I have to get through MS Access and found out partition by and row_number() are not supported.
Any approach will be appreciated
Here's the query:
INSERT INTO TARGET_TABLE (COL1, CV1, CV2)
SELECT st.DontCareValue, st.CV1, st.CV2
FROM(
select DontCareValue, CV1, CV2,
row_number() over (partition by CV1, CV2 order by DontCareValue) as rn
From sourceTable
where length(CV1) >= 2) st
where st.rn = 1
and not exists(select 1 from TARGET_TABLE tt
where tt.CV1= st.CV1
and tt.CV2 = st.CV2)