占总销售成本的15%

时间:2014-10-21 21:23:30

标签: mysql sql select sum

难以弄清楚如何计算销售表总数的15%

这是我迄今为止所得到的(总和)。发现在同一查询中显示总销售额和15%销售额的困难..

SELECT SUM(prices) AS total sales FROM sales;

2 个答案:

答案 0 :(得分:3)

你可以将总和乘以0.15:

SELECT SUM(prices) AS total_sales,
       SUM(prices) * 0.15 AS fifteen_percent
FROM   sales;

答案 1 :(得分:2)

SELECT SUM(prices) AS [total sales], ((15.0/100.0) * SUM(prices)) AS [15 percent of sales] FROM sales;