Sql server 按查询分组无法正常工作sql server 2005
我应该得到这样的结果,我试过分组,但没有任何效果像我在这里需要的那样Sql server 按查询分组无法正常工作sql server 2005,sql-server,sql-server-2005,Sql Server,Sql Server 2005,我应该得到这样的结果,我试过分组,但没有任何效果像我在这里需要的那样 Exp Reason CreditAccounts Points 2012-01-30 02:11:58.830 Inactive 1 5 2012-01-31 02:11:58.827 Inactive 1 5 2012-02-01 02:12:02.130 Inactiv
Exp Reason CreditAccounts Points
2012-01-30 02:11:58.830 Inactive 1 5
2012-01-31 02:11:58.827 Inactive 1 5
2012-02-01 02:12:02.130 Inactive 2 10
2012-02-03 02:11:58.820 Inactive 4 20
2012-02-03 02:12:02.120 Inactive 2 10
2012-02-04 02:12:02.113 Inactive 4 20
这方面的任何解决方案都会很好
谢谢
普林斯看起来你想按日期分组?您忽略了包含关于表定义或需求的任何附加信息,但可能需要类似的内容
Exp Reason CreditAccounts Points
2012-01-30 02:11:58.830 Inactive 1 5
2012-01-31 02:11:58.827 Inactive 1 5
2012-02-01 02:12:02.130 Inactive 2 10
2012-02-03 02:11:58.820 Inactive 6 30
2012-02-04 02:12:02.113 Inactive 4 20
谢谢,很好,马丁·史密斯
SELECT MIN(Exp) AS Exp,
Reason,
SUM(CreditAccounts) AS CreditAccounts,
SUM(Points) AS Points
FROM SomeTable
GROUP BY Reason, DATEDIFF(DAY, 0, Exp)