SUM AND MAX的SQL代码

时间:2014-01-02 14:59:58

标签: sql

我有下表,想写一个SQL语句来总结每篇文章和Extract Maximum? :

| A | 3 |
| B | 6 |
| A | 4 | 

输出:A = 7,B = 6.

2 个答案:

答案 0 :(得分:1)

select columnname,sum(columnname),max(expression/columnname)
from tablename 
group by columnname

答案 1 :(得分:0)

像这样;

SELECT Article, SUM(Num_Column)
FROM Table_Name
GROUP BY Article
ORDER BY Article