How do i bring the rows distinctly by OrderID and those who has ProductID 1. if there is no 1 then bring 2
I've tried:
Select DISTINCT OrderDetailID,OrderID,ProductID,Quantity from Products 
ORDER BY OrderID,ProductID
| OrderDetailID | OrderID | ProductID | Quantity | 
|---|---|---|---|
| 1 | 10248 | 1 | 12 | 
| 2 | 10248 | 2 | 10 | 
| 3 | 10249 | 1 | 5 | 
| 4 | 10250 | 1 | 9 | 
| 5 | 10250 | 2 | 40 | 
| 6 | 10251 | 2 | 10 | 
| 7 | 10252 | 1 | 35 | 
| 8 | 10252 | 2 | 15 | 
| 9 | 10253 | 2 | 6 | 
| 10 | 10254 | 2 | 15 | 
Output should be like this:
| OrderDetailID | OrderID | ProductID | Quantity | 
|---|---|---|---|
| 1 | 10248 | 1 | 12 | 
| 3 | 10249 | 1 | 5 | 
| 4 | 10250 | 1 | 9 | 
| 6 | 10251 | 2 | 10 | 
| 7 | 10252 | 1 | 35 | 
| 9 | 10253 | 2 | 6 | 
| 10 | 10254 | 2 | 15 | 
 
     
    