我在SQL Server中的表像如在atendence第1列上表如下如何修改查詢中使用asp.net C#與SQL Server獲得月度考勤報告
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
表示現在和0表示不存在
當我試圖顯示一個月明智atendence報告,我能夠計算總報告沒有月度明智..
我用下面的查詢
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
,但我想作爲使用asp.net網格視圖如下
_____________________________________________________________________
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
________________________________________________________________________
顯示它....請幫助修改查詢
在此先感謝
幽靈....我已經檢查,仍然面臨同樣的問題.... – Ramya