1

这是我的查询:

SELECT      p.Company
        ,   p.Project_ID
        ,   p.Name as 'Project_Name'
        ,   p.Company
        ,   t.Name as 'Task_Name'
        ,   r.Owner
        ,   t.Status
        ,   r.Work_Date
        ,   r.Minutes_Spent
        ,   r.Type
        ,   r.Description
FROM        TK_Project      p 
INNER JOIN  TK_Task         t
ON          p.Project_ID    = t.Project_ID 
JOIN        TK_Time_Record  r
ON          t.ID            = r.Task_ID
WHERE       p.Company       = 248 
AND         p.Name          = 'Technical Support'
AND         r.Work_Date     BETWEEN  '01/01/2012'  AND  '05/02/2012'
AND         r.Type          NOT LIKE '%non%'
--AND       (
--                  r.Type = 'Programming-Billable' 
--              OR  r.Type = 'Consulting-Billable'
--          )
AND         (
                    r.Type = 'Data Maintenance' 
                OR  r.Type = 'Tech Support-Billable' 
                OR  r.Type = 'Training'
            )
ORDER BY    r.Work_Date DESC

这是它返回的数据:

Company Project_ID Project_Name      Company Task_Name         Owner   Status    Work_Date             Minutes_Spent Type                   Description
------- ---------- ----------------- ------- ----------------- ------- ------- ----------------------- ------------- --------------------- ------------
248     512        Technical Support 248     Technical Support Tim     Started 2012-03-06 00:00:00.000      15       Tech Support-Billable Notes.
248     512        Technical Support 248     Technical Support Patrick Started 2012-02-24 00:00:00.000      15       Data Maintenance      Notes.
248     512        Technical Support 248     Technical Support Tim     Started 2012-02-24 00:00:00.000      15       Tech Support-Billable Notes.
248     512        Technical Support 248     Technical Support Tim     Started 2012-02-14 00:00:00.000      15       Tech Support-Billable Notes.
248     512        Technical Support 248     Technical Support Tim     Started 2012-01-05 00:00:00.000      15       Tech Support-Billable Notes.
248     512        Technical Support 248     Technical Support Tim     Started 2012-01-04 00:00:00.000      15       Tech Support-Billable Notes.

asp.net 或 sql 中获取 Minutes_Spent 列总数的最佳方法是什么?我试图让 WITH ROLLUP 工作,但无法正常工作。我试过 COMPUTE 但不能返回多个结果集(也许我可以但不确定如何在 asp.net 中访问它)

4

1 回答 1

1

好吧,考虑到您的问题,我想侧面请求不是您想要的。
至于 asp,我发现这篇文章可能会让您感兴趣,尽管您已经尝试过:
如何计算asp.net中数据表列的总和?

如果过滤器有问题,请查看这篇文章:
具有计算但没有过滤器的 SUM 数据表列

我希望它会帮助你!

于 2012-05-02T22:36:39.523 回答