drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable
drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable
drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable
drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable
drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable
drop procedure mCount
go
create procedure mCount
@month int
as
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempTable'))
drop table #tempTable
create Table #tempTable
(
ID int IDENTITY PRIMARY KEY,
userName varchar(50),
minusCount int
)
declare minusCount cursor for
select distinct userId from AccountTable
declare @userId varchar(50)
declare @preMonthScore int
declare @currentMonthScore int
declare @minusCount int
declare @userName varchar(50)
declare @minus int
set @minus=@month-1
open minusCount
fetch next from minusCount into @userId
while @@fetch_status=0
begin
fetch next from minusCount into @userId
set @currentMonthScore=(select scoreCount from mountCount(@month,@userId))
set @preMonthScore=(select scoreCount from mountCount2(@minus,@userId))
set @minusCount=@preMonthscore-@currentMonthScore
set @userName=(select [name] from userTable where userid=@userId)
insert into #tempTable values (@userName,@minusCount)
end
close minusCount
deallocate minusCount
select top 3 * from #tempTable