Calculating a grand total using two columns with a percentage?
I have built a table that includes various items, item id and prices, etc. - I also have a list of stored customers in my database and the items they bought.
I would like to be able to calculate my total VAT (16%) for these items, only those that have been sold (not unsold items).
I tried this code:
SELECT sum(items.price*sales.amount) as 'Total Sold', sum((items.price*sales.amount)*0.16) AS 'Estimated Total Vat Amount'
FROM sales
But the next result was "unknown column" even though it exists. When searching the web, I recommend using "inner join", but if possible, I would prefer to use something else.
Is it possible? if so what can i use to get my result?
Thank.
+3
source to share