我正在构建一个报告,输出应该是这样的(示例):
['11/2012', 5, 2, 0]
['10/2012', 7, 1, 0]
['09/2012', 2, 3, 0]
['08/2012', 0, 0, 1]
['07/2012', 0, 2, 1]
['06/2012', 2, 1, 0]
['05/2012', 3, 1, 1]
['04/2012', 2, 2, 1]
['03/2012', 5, 0, 0]
['02/2012', 7, 1, 0]
['01/2012', 2, 0, 0]
['12/2011', 3, 0, 1]
对于月份部分,我需要获取实际月份,然后列出一年前。我已经用这段代码做到了这一点:
<%
DataAtual_PeriodoInicial= Now
DataFinal_PeriodoInicial= DateAdd("m", -13, Now)
DO WHILE Datediff("m", DataAtual_PeriodoInicial, DataFinal_PeriodoInicial) <> 0
%>
['<% Response.Write(Right("0" & Month(DataAtual_PeriodoInicial), 2)) %>/<% Response.Write(Year(DataAtual_PeriodoInicial)) %>', X, Y, Z]<br>
<%
DataAtual_PeriodoInicial= DateAdd("m", -1, DataAtual_PeriodoInicial)
LOOP
%>
所以这正在生成:
['11/2012', X, Y, Z]
['10/2012', X, Y, Z]
['09/2012', X, Y, Z]
['08/2012', X, Y, Z]
['07/2012', X, Y, Z]
['06/2012', X, Y, Z]
['05/2012', X, Y, Z]
['04/2012', X, Y, Z]
['03/2012', X, Y, Z]
['02/2012', X, Y, Z]
['01/2012', X, Y, Z]
['12/2011', X, Y, Z]
现在我必须抛出一些数字而不是 X、Y 和 Z。我有一个包含如下数据的表格:
11 2012 X
10 2012 X
10 2012 X
10 2012 X
10 2012 Y
10 2012 Y
10 2012 Z
10 2012 Z
10 2012 Z
9 2012 X
9 2012 X
9 2012 X
9 2012 Y
9 2012 Z
9 2012 Z
8 2012 X
8 2012 X
8 2012 Y
8 2012 Y
8 2012 Y
8 2012 Y
8 2012 Y
...
我从这个选择开始:
SELECT
datepart(month,SentDate) AS Mes,
datepart(year,SentDate) AS Ano,
EventType
FROM
SomeTable
ORDER BY
SentDate DESC
我尝试了一些分组,但没有成功。我需要某种计数吗?和?我怎样才能完成这个问题顶部的输出?
谢谢!