I have bank transaction data to select two functions in a single query.
I have data like this

```
|ID  |  name  | amount |
|----|--------|--------|
| 1  |  xxx   | 1000   |
| 2  |  yyy   | -500   |
| 3  |  qqq   | 1500   |
| 4  |  ggg   | -1000  |
------------------------

```

I want like this

```
-------------------------------------------
|ID  |  name  | amount | sell | buy | cum |
|----|--------|--------|------|-----|-----|
| 1  |  xxx   | 1000   | 1000 | n/a |1000 |
| 2  |  yyy   | -500   | n/a  |-500 | 500 |
| 3  |  qqq   | 1500   | 1500 | n/a | 2000|
| 4  |  ggg   | -1000  | n/A  |-1000| 1000|
------------------------------------------

```

My code is.

```
SELECT ID, name, amount,
CASE WHEN amount >=0 THEN amount END AS sell,
CASE WHEN amount <=0 THEN amount END AS buy,
From bank
Join (select @csum := @csum + amount as csum from bank
Join (select @csum := 0) r order by ID);

```