Hello MySQL specialists,
I am working on a wordpress website referencing used vehicles.
I have a table called "wp_686591_postmeta" in which I have various data including the 'brand' and the 'selling price'.
I wrote the below sql query in phpMyAdmin:
SELECT pm.meta_value as 'brand', COUNT(pm.meta_key) as 'number of vehicles' FROM wp_686591_postmeta pm WHERE pm.meta_key = 'brand' GROUP BY pm.meta_value
As a result I get two columns : the car brand and the total number of vehicles for each brand no matter what the post_status is.

I need to add a third column that sums all selling prices of each brand. The meta_key is "selling-price".
Because I am very new in MySQL, I am struggling to do two things :
- I need to add a third column called "Total" to display the sum of all selling prices for each brand.
The result should be :

- I need to do the same but by post_status "publish" and "pending".
I hope someone may assist. Thanks a lot.