This is my query:
SELECT llx_societe.nom as "Customer",
sum(llx_facturedet.total_ht) AS "2020"
FROM llx_facture AS t
LEFT JOIN llx_societe ON t.fk_soc = llx_societe.rowid
LEFT JOIN llx_facturedet ON t.rowid = llx_facturedet.fk_facture
LEFT JOIN llx_product ON llx_facturedet.fk_product = llx_product.rowid
WHERE date_format(t.datef,'%Y') = '2020' AND t.entity IN (1,3)
GROUP BY llx_societe.nom
ORDER BY 2 DESC;
Just like the results of 2020, i want to add 2 more columns named 2019 and 2018. I thought of union but it did not work. I am stuck here kindly guide me