这是我的查询:
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 中访问它)