22,209
社区成员
发帖
与我相关
我的任务
分享
ALTER proc [dbo].[sp_AssessInfo]
(
@starttime datetime,
@endtime datetime
)
as
begin
declare @i int --
declare @row int --
declare @LoginNum int -- 登录次数
declare @Zzjg_id int --
declare @Yh_id int --
SET NOCOUNT ON;
--if exists (select * from dbo.sysobjects where id = object_id(N'[CL].[TempCountOne]') and OBJECTPROPERTY(id, N'IsTable') = 1)
-- drop Table [CL].[TempCountOne]
-- ---创建统计表
--Create Table TempCountOne(
-- id int IDENTITY (1, 1) NOT NULL ,
-- zzjg_id int,
-- yh_id int,
-- loginNum int
--)
IF OBJECT_ID ( 'tempdb..#TotalRecord_PS') IS NOT NULL
drop table #TotalRecord_PS;
create table #TotalRecord_PS(
id int IDENTITY (1, 1) NOT NULL ,
zzjg_id int,
yh_id int,
loginNum int
);
--select
-- a.zzjg_id,b.yh_id,c.userLoginTime,count(c.userLoginTime) as LoginNum
--from
-- tb_zzjg a,tb_yh b,tb_loginLog c
--where
-- a.zzjg_id=b.zzjg_id
--and
-- b.yh_id=c.userID
--and
-- userLoginTime between @starttime and @endtime
--group by
-- a.zzjg_id,b.yh_id,c.userLoginTime
select @Zzjg_id=zzjg_id from tb_zzjg
select @Yh_id=yh_id from tb_yh where zzjg_id=@Zzjg_id
select @LoginNum=count(c.userLoginTime) from tb_zzjg a,tb_yh b,tb_loginLog c
where userID=@Yh_id and userLoginTime between @starttime and @endtime
insert into #TotalRecord_PS(zzjg_id,yh_id,loginNum) values(@Zzjg_id,@Yh_id,@LoginNum)
select * from #TotalRecord_PS
end
create proc test
(
@starttime,
@endtime
)
as
begin
select
a.zzjg_id,b.yh_id,convert(varchar(10),c.login_time,120) as login_time,count(c.login_time) as 登录的总次数
from
组织机构 a,用户表 b ,用户登录表 c
where
a.zzjg_id=b.zzjg_id
and
b. yh_id=c. yh_id
and
logintime between @starttime and @endtime
group by
a.zzjg_id,b.yh_id,convert(varchar(10),c.login_time,120)
end
create proc test
(
@starttime,
@endtime
)
as
begin
select
a.zzjg_id,b.yh_id,c.login_time,count(c.login_time) as 登录的总次数
from
组织机构 a,用户表 b ,用户登录表 c
where
a.zzjg_id=b.zzjg_id
and
b. yh_id=c. yh_id
and
logintime between @starttime and @endtime
group by
a.zzjg_id,b.yh_id,c.login_time
end