- - Code, Content, and Presentation
- -- Databases
- ---- Calculate sum of three columns (net sales, VAT, total sales
eelixduppy - 6:50 pm on Feb 29, 2012 (gmt 0)
Perhaps something like this?
select sum(NetAmount) NetSale from sales
or you can just rewrite each result in terms of the sum:
select sum(NetAmount) as NetSale, format((sum(NetAmount)/4),2) as VAT,(sum(NetAmount)*5/4) as TotalSale
However, something like this should really be put into a stored procedure.
Thread source: http://www.webmasterworld.com/databases_sql_mysql/4422124.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com