根据类别计算每周平均时间

时间:2017-07-03 02:06:30

标签: sql time calendar average categories

我有一张表格,显示在给定日期之间关闭的门票详细信息。使用这些列:

Category,
ticket_Number, 
RequestOpenDate, 
RequestClosedDate,
time_take_In_hours

每张门票都属于特定类别。基于类别,我想生成每周关闭票证的平均时间。

示例:对于给定日期 '01 -01-2017' '01 -04-2017'我希望此输出:

**Category**    **Weekly_Avg_In_Hours**
Category1               122
Category2               100
Category3                89

我尝试了很多方法,最终设法低于输出:

**Month**   **Category**    **Week**    **Avg_Time_In_Hours**
January       Category1       Week1       100
January       Category2       Week1        90
January       Category3       Week1        80
January       Category1       Week2        90
January       Category2       Week2        80
January       Category3       Week2       100
February      Category1       Week1        80
February      Category2       Week1        50
February      Category3       Week1       100
February      Category1       Week2        90
February      Category2       Week2        76
February      Category3       Week2       100

另一个问题是周数 我想将2017年7月1日视为第1周,7月2日至8日视为第2周... 7月30日和31日为第6周:

enter image description here

0 个答案:

没有答案