This is my table:

```
Ref Num   Status    Task Status   Task N
-----------------------------------------
TB011       RET       Null        0  
TB012       RET       Null        0  
TB013       INP       Ready       100  
TB013       INP       Null        0  
TB013       INP       Null        0  
TB014       INP       In Process  100  
TB014       INP       Null        0  
TB014       INP       Null        0  
TB015       INP       Completed   100  
TB015       INP       Ready       200  
TB015       INP       Null        0  
TB016       INP       Ready       100  
TB016       INP       In Process  150  
TB016       INP       Null        0  
TB017       INP       Completed   100  
TB017       INP       In Process  150  
TB017       INP       Ready       199  
TB017       INP       Null        0  

```

I need to get unique row of each "Ref Num" where:

* `if Status = RET` there only going to be one row where Task Status will always be null
* `if Status = INP` I need only the first row where Task Status is not Completed

I have add "Task N" row with is a number, maybe it will help 

The result should look like that:

```
Ref Num   Status    Task Status   Task N   
------------------------------------------
TB011       RET       Null        0  
TB012       RET       Null        0  
TB013       INP       Ready       100   
TB014       INP       In Process  100    
TB015       INP       Ready       200  
TB016       INP       Ready       100  
TB017       INP       In Process  150  

```

! I have many more columns after Ref Num, Status, Task Status, Task N with different data and I also need them.