漫漫技术人生路

C#

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

posted on 2006-10-12 12:11  javaca88  阅读(236)  评论(0编辑  收藏  举报