I have two Tables T1 and T2

T1

```
Id name open   receive close
1  jon  5000    0      5000
2  jim  6000    0      6000
3  ben  9000    0      9000

```

T2

```
Id name receive
1  jon   500
3  ben   200
2  jim   700
1  jon   500
2  jim   700
3  ben   100

```

First thing that I want how to order the T2 with update query.

```
Id name receive
1  jon   500
1  jon   500
2  jim   700
2  jim   700
3  ben   100
3  ben   200

```

After that, I Want update T1 like this

```
Id name  open   receive close
1  jon   5000   1000    4000
2  jim   6000   1400    4600
3  ben   9000    300    8700

```

I'm using Sqlite