How to make a double query in the same MySql table?

Below, I explain what I do and what I need, I now leave a statement of the goal table and the query I am using.

Target table (line_count_fact):

product_id | unds | achat_sales
10517931 | 2 | Purchase
10517929 | 4 | Sale
10517929 | 2 | Sale
10517939 | 6 | Purchase
10517931 | 3 | Sale 

This is my request:

SELECT
fact_line_contability.product_id,
SUM (fact_contabilidad_lineas.unds) as unds,
fact_contabilidad.compra_venta

DE fact_contabilidad, fact_contabilidad_lineas

WHERE fact_line_contability.series = concat_ws (& # 39; - & # 39 ;, fact_contabilidad.id_serie, fact_contabilidad.serie_num)
AND fact_line_contability.iduser = 98
AND fact_contability.iduser = 98
AND fact_contabilidad.compra_venta = & # 39; Venta & # 39;
AND fact_line_contractability.product_id> 10517927

GROUP BY fact_line_contability.product_id

Result:

product_id | unds | achat_sales
10517929 | 6 | Sale
10517931 | 3 | Sale 

I have not shown the table (fact_contabilidad) because it is not necessary, it does not influence my question and in this way, the question is a little cleaner. The query works well, but it only removes the lines compra_venta = Venta.

What I need to go out is:

1 column sum of products grouped by product_id and compra_venta = Sale.

1 column sum of products grouped by product_id and compra_venta = Purchase.

Expected result:

product_id | Sale | Purchase
10517929 | 6 | 6
10517931 | 3 | 2

Can you guide me? I can not think of how to do it.