SQL Server单条sql实现分页和总行数
SQL Server单条sql实现分页和总行数
shawntime 发表于1年前
SQL Server单条sql实现分页和总行数
  • 发表于 1年前
  • 阅读 25
  • 收藏 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
共有 人打赏支持
粉丝 33
博文 75
码字总数 79249
×
shawntime
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: