```
ID  DepID   Status
------------------
000 54  0
000 12  1
141 14  0
141 56  1
000 12  0
000 89  1

```

I have the above table in which I have the `depID`. The following is the output I need:

```
ID  DepOld  DepNew
-------------------
000 54        12
141 14        56
000 12        89

```

Status of 0 means its old and 1 means new. How do I get the above output, considering it's in one table?

I can't use the `IN` clause.

I tried the following

```
SELECT 
   ID,
   Max(CASE
          WHEN Status = 0 THEN DepID
       END) DepOld,
   Max(CASE
          WHEN Status = 1 THEN DepID
       END) DepNew
FROM   
   tablename
GROUP BY 
   ID 

```

but this the output I get

```
Id   DepOld  DepNew
--------------------
000  54      54
000  12      NULL
141  14      14
141  56      Null

```

if i pass depID=54 then this output is what i want

ID DepOld DepNew

---

```
000  54      12

```