Home > Database > Mysql Tutorial > How to solve the problem of not sorting when sqlServer uses ROW_NUMBER

How to solve the problem of not sorting when sqlServer uses ROW_NUMBER

coldplay.xixi
Release: 2020-07-24 17:43:27
forward
3316 people have browsed it

How to solve the problem of not sorting when sqlServer uses ROW_NUMBER

Set sqlServer not to sort when using ROW_NUMBER

--1. Seeing that NHibernate writes paging like this, I feel that it is easier to understand when writing (it should not be efficient) Question?)
--with is just an alias?

[sql]

with query as (select ROW_NUMBER() over(order by (select 0)) AS ROWNUM, * FROM Product) 
select * from query where ROWNUM BETWEEN 5 AND 10
Copy after login

--2.ROW_NUMBER must refer to over (order by **). Sometimes I don’t want to sort at all and want to sort in the original order (sorting also requires Time)

--The method is:

select ROW_NUMBER() over(order by (select 0)) AS ROWNUM,* FROM Product
Copy after login

The sorting is:

select Row_number() over(order by Oper_Date desc) AS ROWNUM,* FROM Product
Copy after login

Related learning recommendations: mysql video Tutorial

The above is the detailed content of How to solve the problem of not sorting when sqlServer uses ROW_NUMBER. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template