SQL Server单条sql实现分页和总行数
SQL Server单条sql实现分页和总行数
蓝汀华韶 发表于2年前
SQL Server单条sql实现分页和总行数
  • 发表于 2年前
  • 阅读 35
  • 收藏 1
  • 点赞 0
  • 评论 0

移动开发云端新模式探索实践 >>>   

SQL Server单条sql实现分页和总行数

SELECT
	CustomerId AS customerId,
	Phone AS userMobile,
	Name AS userName,
	FirstOrderTime AS firstOrderTime,
	LatestOrderTime AS lastestOrderTime,
	CustomerLevel AS customerLevel,
	Call400Count AS call400Count,
	OnlineOrderCount AS onlineOrderCount,
	CityId AS cityId,
	CityName AS cityName,
	total AS totalNum
FROM
	(
		SELECT
			CustomerId,
			Phone,
			Name,
			FirstOrderTime,
			LatestOrderTime,
			CustomerLevel,
			Call400Count,
			OnlineOrderCount,
			CityId,
			CityName,
			ROW_NUMBER () OVER (ORDER BY CustomerId DESC) rn,
			COUNT (1) OVER () AS total
		FROM
			CustomerInfo WITH (NOLOCK)
		WHERE
			1 = 1
	) AS t
WHERE
	1 = 1
AND t.rn BETWEEN 1
AND 20
  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 35
博文 76
码字总数 80082
×
蓝汀华韶
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: