![](/img/trans.png)
[英]How to sum the values of a column based on the result of another SELECT query?
[英]How to select sum of column in result of select?
如何在select的結果中選擇列的總和?
SELECT
SUM(your_column) AS Total
FROM
your_table;
......或者這是一個技巧問題嗎? :)
這是一個MySQL聚合的內置函數列表
AVG() Return the average value of the argument BIT_AND() Return bitwise and BIT_OR() Return bitwise or BIT_XOR()(v4.1.1) Return bitwise xor COUNT(DISTINCT) Return the count of a number of different values COUNT() Return a count of the number of rows returned GROUP_CONCAT()(v4.1) Return a concatenated string MAX() Return the maximum value MIN() Return the minimum value STD() Return the population standard deviation STDDEV_POP()(v5.0.3) Return the population standard deviation STDDEV_SAMP()(v5.0.3) Return the sample standard deviation STDDEV() Return the population standard deviation SUM() Return the sum VAR_POP()(v5.0.3) Return the population standard variance VAR_SAMP()(v5.0.3) Return the sample variance VARIANCE()(v4.1) Return the population standard variance
我相信你想要SUM()
SELECT SUM(sales) as "Revenue" FROM details;
SELECT SUM(col)FROM表
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.