mssql 创建存储过程简单实例
2016-06-01 09:36
316 查看
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
相关文章推荐
- Oracle安装及遇到的问题
- Oracle
- mssql 创建函数简单实例
- 关于sql的学习(一)
- redis sentinel 集群监控 配置
- Redis 代理 twemproxy
- MySQL触发器入门
- redis学习
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
- MongoDB快速入门笔记(六)之MongoDB删除文档操作
- centos7 下安装oracle 11g笔记
- Linux下搭建Redis环境
- V$SQL%知多少?
- oracle--delete和truncate的区别
- SQLiteDatabase.cs
- oracle11g在Server08R2服务器上安装部署常见问题
- 【MongoDB】Mongodb集群搭建的三种方式
- Mybatis插入MySQL数据库中文乱码
- Mybatis插入MySQL数据库中文乱码
- 文档数据库RavenDB-介绍与初体验