一、MySQL分页
sql
SELECT column1, column2
FROM table
ORDER BY column1
LIMIT @Offset, @Fetch;
sql
SELECT column1, column2
FROM table
WHERE id BETWEEN @StartId AND @EndId
ORDER BY column1;
二、Sql Server 分页
sql
SELECT column1, column2
FROM table
ORDER BY column1
OFFSET @Offset ROWS
FETCH NEXT @Fetch ROWS ONLY;
三、group by和distinct的主要区别在于它们的作用方式和应用场景
DISTINCT 实际上和 GROUP BY 操作的实现非常相似,它们的实现都基于分组操作,只不过 DISTINCT 是在 GROUP BY 之后的每组中只取出一条记录而已;
注:group by可结合having进行数据过滤