使用Pivot还希望计算页脚中的列总数 [英] Using Pivot also want to calculate total of columns in footer

查看:110
本文介绍了使用Pivot还希望计算页脚中的列总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望此查询的页脚总数为

I want o get total in the footer for this query

SELECT 'Total' AS Total, SUM([Coding]), SUM([Unit Testing]),
       SUM([User Manual]), SUM([Meetings]), SUM([Testing])
FROM (SELECT TOP (100)
      Name,
      [Coding],[Unit Testing],[User Manual],[Meetings],[Testing],
      TaskDate,
      COALESCE([Coding],0) + COALESCE([Unit Testing],0) +
               COALESCE([User Manual],0) + COALESCE([Meetings],0) +
               COALESCE([Testing],0) AS Total
      FROM (SELECT
            TaskTitle As Title,
            Hours,
            Employee_Name AS Name,        
            TaskDate
            FROM TimeSheet TS,
                 employee E,
                 Timesheetdetails TSD,
                 Task T
            WHERE
                TS.EmployeeID = E.Employee_EmpID AND
                TSD.TaskID = T.TaskID AND
                TS.TImeSheetID = TSD.TimeSheetID AND
                T.Status='A' AND
                TS.ProjectID = 43 AND
                TSD.TaskDate >='09/26/2011' AND
                TSD.TaskDate<='10/02/2011'
            ) up
      PIVOT (SUM(Hours) FOR Title IN ([Coding], [Unit Testing], 
                                      [User Manual],
                                      [Meetings],[Testing])) AS pvt           
      ORDER BY TaskDate DESC)          
      GROUP BY SUM([Coding]), SUM([Unit Testing]), SUM([User Manual]),
                   SUM([Meetings]), SUM([Testing])




但其显示错误




but its showing error

推荐答案

乍一看,FROM (SELECT TOP (100)中的开放括号似乎与右括号不匹配.
这可能只是您在复制sql时所犯的错误,但是由于您没有告诉我们您实际上收到了什么错误消息,所以这是我的猜测.

我要说的是,不要告诉我们这不起作用",它显示错误"之类的内容,您最好不提及它,因为它并没有真正的帮助任何试图帮助您解决问题的人.告诉我们我收到此错误消息< the error =" message =">.
At first sight the open parenthesis in FROM (SELECT TOP (100) doesn''t seem to be matched by a closing parenthesis.
That might just be mistake you made when copying the sql, but as you do not tell us what error message you''re actually getting, that''s my guess.

What I''m trying to say, don''t tell us "this doesn''t work", "it shows an error" and the like, you might as well just not mention it as it doesn''t really help anyone who tries to help you resolve your issue. Tell us I get "this error message <the error="" message="">".


这篇关于使用Pivot还希望计算页脚中的列总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆