Let's say i have a table, Product. This contains several Products with different vatpercentages and vatprices:
Product
ArticleId | Price | VatPercentage | VatPrice
--------------------------------------------
1 100 25.0000000000 25
2 80 25.0000000000 20
3 50 8.0000000000 4
4 70 8.0000000000 5.6
5 20 0 0
0
Now i need to build strings using Group_concat and sum prices by vatpercentage where VatPrice is not 0 and price is not 0.
In this case i want the strings to look like this:
VatPercentage: 25% VatPrice: 45
VatPercentage: 8% 9.6
The code i've tried:
select
group_concat('VatPercentage:' ||
CAST(VatPercentage as integer) || '% ' ||
'VatPrice:' SUM(VatPrice),'')
FROM Product
group by VatPercentage having count(Price) > 0
Thanks on forehand
Aucun commentaire:
Enregistrer un commentaire