So I have a 2 table like below:
Item
+-----------------+-------------+
| id | Name | Category |
+-----------------+-------------+
| 1 | Something1 | A |
| 2 | Something2 | B |
| 3 | Something3 | B |
| 4 | Something4 | A |
| 5 | Something5 | A |
+-----------------+-------------+
Buy
+-----------------+-------------+
| id | Name | Number |
+-----------------+-------------+
| 1 | Something1 | 14 |
| 1 | Something2 | 10 |
| 2 | Something1 | 14 |
| 2 | Something5 | 11 |
| 2 | Something3 | 12 |
| 3 | Something4 | 18 |
| 4 | Something3 | 11 |
+-----------------+-------------+
The buy table don't have primary key because id forgein key with another bill table contain id and type(sell/buy/borrow). A bill can contain many items. I can join them one by one
+-----------------+-------------+
|STT | name | Total |
+-----------------+-------------+
| 1 | Something1 | 28 |
| 2 | Something4 | 18 |
| 3 | Something5 | 11 |
+-----------------+-------------+
What I want:
+-----------------+-------------+
|STT | name | Total |
+-----------------+-------------+
| Category: A |
|-------------------------------|
| 1 | Something1 | 28 |
| 2 | Something4 | 18 |
| 3 | Something5 | 11 |
| Category: B |
|-------------------------------|
| 1 | Something3 | 23 |
| 2 | Something2 | 10 |
+-----------------+-------------+
Can it possible with just sql?(Not using temporary table)