I have some data that store in my DB such as:

```
id    nid    name  
1     111    john
2     111    bill
3     222    tom
4     111    boy
5     111    girl
6     111    tim
7     333    jone
8     222    mike
.      .      .

```

and I need to query all id and then grouping all by nid. the expected result is

```
id    nid    name  
1     111    bill
3     222    tom
6     111    tim
7     333    jone
8     222    mike

```

how can i do in one query or any idea?