CREATE procedure [dbo].
[cp_User_Increment]
@channelId int,
@currentPage int,
@pageSize int,
@userId int
as
if @channelId<=0
begin
select
CurrentTime,
Count
from
(
select
*,
ROW_NUMBER() OVER(
ORDER BY CurrentTime
DESC)
AS RowNum
from
(
select
CONVERT(
varchar(
12), AddTime,
111 )
as CurrentTime,
COUNT(
1)
as Count
from Users
where IsDel
=0 and ChannelId
in (
select ChannelId
from Channel_User
where UserId
=@userId)
group by CONVERT(
varchar(
12), AddTime,
111)
)a
)b
where RowNum
BETWEEN (
@currentPage-1)
*@pageSize+1 and @currentPage*@pageSize
end
else
begin
select
CurrentTime,
Count
from
(
select
*,
ROW_NUMBER() OVER(
ORDER BY CurrentTime
DESC)
AS RowNum
from
(
select
CONVERT(
varchar(
12), AddTime,
111 )
as CurrentTime,
COUNT(
1)
as Count
from Users
where IsDel
=0 and ChannelId
=@channelId and ChannelId
in (
select ChannelId
from Channel_User
where UserId
=@userId)
group by CONVERT(
varchar(
12), AddTime,
111)
)a
)b
where RowNum
BETWEEN (
@currentPage-1)
*@pageSize+1 and @currentPage*@pageSize
end
GO
转载于:https://www.cnblogs.com/zoro-zero/p/5548536.html
转载请注明原文地址: https://mac.8miu.com/read-63680.html