如何修改查询以使用 asp.net C# 和 Sql Server 获取每月出勤报告



我在SQL服务器中有一个表,如下所示

rollno   date           atendence
  1      05/27/2015       1
  2      05/27/2015       0
  3      05/27/2015       1
  4      05/27/2015        1
  1      04/27/2015        1
  2      04/27/2015        1
  3      04/27/2015        1
  4      04/27/2015        1

在上表中的附录中,第 1 列表示存在,0 表示不存在

当我尝试显示按月显示报告时,我能够计算总报告而不是每月报告。

我使用了以下查询

    select rollno,  sum(case when satendence.atendence != 0  then satendence.atendence else 0 end)
as atendence, (select count(day) from atenmaster) as total,
(convert (money, 100.0 * sum(case when satendence.atendence != 0  then satendence.atendence else 0 end) / (select count(day) from atenmaster), 1)) as percentage
from satendence 
group by rollno

上述查询的输出如下所示

rollno     atendence   total      percentage
  1           2          2         100.00
  2            1          2          50.00
  3            2          2         100.00
 4             2         2          100.00

但我想显示如下

_____________________________________________________________________
                 April                          may
______________________________________________________________________
rollno    atendence    total     percentage   atendence total percentage
_________________________________________________________________________
1           1           1         100.00         1          1     100.00
2           1            1         100.00        0           1    0.00
3           1            1         100.00        1           1     100.00
________________________________________________________________________

使用网格视图 asp.net。

首先确认是否iTextSharp DLL 添加到项目中的dll引用中,然后确保在代码中包含正确的命名空间。考试将是:

using iTextSharp.text;
using iTextSharp.text.pdf;

只需确保在项目和代码中正确引用所有这些内容即可。如果没有,则需要为 iTextSharp 添加引用。

希望这有帮助。

确保 iTextSharp 在托管网站的 Web 服务器中可用。

将 iTextSharp.dll 移动或复制到 Web 服务器中的 GAC - c:\windows\assembly 中

您是否发布了您的应用程序?查看错误消息的内容。将 iTextSharp.dll 放入 Web 服务器的 bin 文件夹中。将其移动到 GAC 中不是一个好方法,因为并非所有应用程序都需要此 DLL。

相关内容

最新更新