TSQL Group问题

时间:2013-01-25 02:00:05

标签: sql sql-server tsql group-by

下图显示了一组带有列标题的结果:

  

TotalEnquires Commission TotalBusinessWritten TotalPaidOut1 formname

我需要按formname进行分组,并获取SUM的每个分组列的totalenquires, commission, totalbusinesswrittenm, totalpaidout1

有人可以帮忙吗?

http://www.gumpshen.com/misc/tsql-help.png

3 个答案:

答案 0 :(得分:1)

你的问题是什么?

SELECT formname, SUM(TotalEntries), SUM(TotalBusinessWritte), SUM(Commission), SUM(TotalPaidOut1)
FROM table
GROUP BY formname

答案 1 :(得分:1)

SELECT formname, SUM(totalenquires), SUM(commission), SUM(totalbusinesswrittenm), SUM(totalpaidout)
FROM table
GROUP BY formname

答案 2 :(得分:1)

    SELECT formname,
      SUM(TotalEnquires),
      SUM(Commission),
      SUM(TotalBusinessWritten),
      SUM(TotalPaidOut1)
    FROM YourTable
    GROUP BY formname