本文介绍了在SQL Server中按一栏汇总的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我希望仅按表的列汇总查询,其余部分应按原样显示.
但是当我按条款在分组中使用它们时,我面临的汇总问题将应用于表的每一列.
有人可以提出解决方案吗?

Hi friends

I want ot rollup my query by only column of the table and rest should come as it is.
But the problem i am facing the rollup is applied on each column of the table when i am using them in the group by Clause .
Can anyone please suggest a solution?

推荐答案


select
     sum(aggregation_field) over (partition by GroupingField)
    ,otherfield2
    ,otherfield2
from
    dbo.table



您可以按其他字段分组,也可以完全不分组.
请注意,这样您将获得< aggregation_field>的总和.在每一行中.



You can group by another field or not group at all.
Note that with this you will get the sum of <aggregation_field> in every row.


这篇关于在SQL Server中按一栏汇总的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:46