SQL Server单条sql实现分页和总行数
SQL Server单条sql实现分页和总行数
本杰明警官 发表于2年前
SQL Server单条sql实现分页和总行数
  • 发表于 2年前
  • 阅读 29
  • 收藏 1
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

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
共有 人打赏支持
粉丝 32
博文 75
码字总数 79249
×
本杰明警官
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: