Need help de-dup a table based on specific columns criteria

5 Views Asked by At

I am Working on a table with duplicated rows and need help to de-dup it based on three specific columns criteria. My first column contains the main duplicated IDs. My final result will be based on the last three columns "within_1Yr", "Guilty", "Convict". These 3 columns in the table can be a combination of values like such: Columns to be used as criteria to de-dup

My main table looks something like this: table to De-dup

Basically, I would like to de-dup based on the values on the last three columns by order of preference like this: Order of preference for de-dup

So in summary I would like to extract a unique row for each MID based on the values of the last three columns by order of preference. Meaning a row/rows with corresponding values Within_1Yr Guilty Conviction Yes G Yes_Convicted

will be extracted and with a unique ID and the query will then search the other MIDs and so on.

I was able to generate the above table using MySQL but I am honestly at my wits end and do not know how to de-dup the table and get the result needed. Any suggestions or advices are greatly appreciated, thank you. Wis-SQLnoob

0

There are 0 best solutions below