【发布时间】:2012-01-20 05:02:26
【问题描述】:
我已经尝试了好几个小时来解决问题,但我还没有想出合适的解决方案。
我在 SQL Server 中有一个名为 EmailTasks 的表:
Id | HasFailed | CreateDate
19 | 1 | 10/11/2011
29 | 0 | 09/11/2011
15 | 1 | 14/12/2011
我想构建一个接受两个参数的存储过程:@beginDate、@endDate。
它从表EmailTasks(即CreateDate在@beginDate和@endDate之间)选择相关记录,并返回下表3列:
-
TotalEmails:邮件总数, -
Failed:失败的电子邮件数量(hasFailed = 1), -
Suceess:成功的邮件数量(hasFailed = 0)。
例如:sp_GetEmailTemplateStatistics('08/11/2011', '11/11/2011') 将返回:
TotalEmails | Failed | Suceess
2 | 1 | 1
请注意:Id=15 的记录不计算在内,因为CreateDate (14/12/2011) 大于参数@endDate。
【问题讨论】:
标签: asp.net .net sql sql-server stored-procedures