Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server : help removing duplicates in alternating rows
    primarykey
    data
    text
    <pre><code>Column 0 Column 1 Column 2 Column 3 Column 4 csus 00287y109 38 NULL 169 mbus 01185pag4 NULL NULL 1 mbus 01185pag4 100 NULL 18 mbus 018033DR8 100 NULL 5 psus 20002309 26 NULL 5 cbus 025816aq2 NULL NULL 169 cdus 02586tbj2X 101 NULL 1 cdus 02586tbj2X NULL NULL 1 </code></pre> <p>I need to remove duplicate rows from this table named combined. However not all rows are duplicated nor are the duplicate rows identical in every column. An example duplicate is row 2 and row 3. The criteria for removal is if a row exists where Column 0 and Column 1 (these are the actual column headers) are identical, keep the row which has a value in Column 2, drop the row with NULL in Column 2 if a duplicate row exists with a value in Column 0 and Column 1 and Column 2. Null values are okay as you see in Column 2, row 6 because this is not duplicated with any other row based on my criteria which focuses on the first three columns. Null is not okay if Column 0 and Column 1 are duplicated. Column 3 is always NULL and it does not matter if Column 4 is duplicated or not. The final two rows, rows 7 and 8 are also duplicated. I would want to keep row 7 because it has a value in Column 2.</p> <p><strong>Added</strong> the expected result</p> <pre><code>Column 0 Column 1 Column 2 Column 3 Column 4 csus 00287y109 38 NULL 169 mbus 01185pag4 100 NULL 18 mbus 018033DR8 100 NULL 5 psus 20002309 26 NULL 5 cbus 025816aq2 NULL NULL 169 cdus 02586tbj2X 101 NULL 1 </code></pre> <p>In the desired result Row 2 and row 8 have been removed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload