使用两个参数sql在mysql中添加相同的值

I have a table trade as follows:-

bm  | m   | price | amount | total    | status
USD | BTC | 0.01  | 1      | 0.01     | active
USD | BTC | 0.01  | 2.5    | 0.025    | active
USD | BTC | 0.4   | 0.5    | 0.020    | active 
USD | BTC | 0.4   | 0.22   | 0.088    | active

I want to add amounts of duplicate price i.e 0.01 and 0.4 as well as total together in one output where status is active and show them so that the result is like:-

price | amount  | total
0.01  | 3.5     | 0.035
0.4   | 0.722   | 0.108

You could group according to the price and sum the other columns:

SELECT   price, SUM(amount), SUM(total)
FROM     trade
WHERE    status = 'active'
GROUP BY price

try this with group by:

select price, sum(amount) as amount,sum(total) as total
from tablename where status='active'
group by price

you could use aggregation function sum() and group by price

select   , price , sum(amount) , sum(total) 
from my_table  
group by   price  

you can try something like this:

SELECT *, sum(amount) AS totalAmount,sum(total) AS total 
FROM TABLE_NAME 
GROUP BY price;