to jiangsheng(蒋晟.Net[MVP]) : 小弟刚开始学习.net,还不了解,能不能告诉直接查找的地址。谢谢。
select 部门=B.sectionname, 用户名称=A.username 1月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=1), 2月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=2), ...... 12月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=12), 全年合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid), 排名=(select sum(1) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and eventnum<=C.eventnum) from 用户数据表 A ,部门数据表 B, 事件数据表 C where A.userid=C.userid and B.sectionid=C.sectionid and year(C.eventdate)='某一年'
用户名称=A.username
1月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=1),
2月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=2),
......
12月合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and month(C.eventdate)=12),
全年合计=(select sum(eventnum) from 事件数据表 where sectionid=B.sectionid and userid=A.userid),
排名=(select sum(1) from 事件数据表 where sectionid=B.sectionid and userid=A.userid and eventnum<=C.eventnum)
from 用户数据表 A ,部门数据表 B, 事件数据表 C
where A.userid=C.userid and B.sectionid=C.sectionid
and year(C.eventdate)='某一年'