当前位置:网站首页>[untitled] database - limit the number of returned rows
[untitled] database - limit the number of returned rows
2022-04-23 06:25:00 【Wood acridine】
The following is the statement that the database limits the number of returned rows ,SELECT TOP Clause is used to limit the number or percentage of rows returned in the query result set . Because the order of rows stored in the table is unpredictable , therefore SELECT TOP The statement is always the same as ORDER BY Clauses are used together . result , The result set is limited to the first N Number of ordered lines . Here is the SELECT Of the statement TOP Syntax of clause :
In this grammar , SELECT Statements can contain other clauses , Such as : WHERE , JOIN , HAVING and GROUP BY .expression - TOP The keyword is followed by an expression , It specifies the number of rows to return . If you use PERCENT , The expression is evaluated as a floating-point value , Otherwise, convert it to BIGINT value .PERCENT - PERCENT Keyword indicates before the query returns N Percentage of rows , among N Is the result of the expression .WITH TIES - WITH TIES Used to return more rows , Its value matches the last row in the finite result set . Please note that , WITH TIES It may cause more rows to be returned than specified in the expression .
OFFSET and FETCH Clause is ORDER BY Clause options . They are used to limit the number of rows returned by the query . Must be OFFSET and FETCH Clause and ORDER BY Clauses are used together OFFSET and FETCH Clause is better than implementation TOP Clause is more suitable for implementing query paging solution. The following is OFFSET and FETCH Syntax of clause :
In the above grammar ,OFFSET Clause specifies the number of rows to skip before starting to return rows from the query . offset_row_count It can be a constant greater than or equal to zero , Variables or parameters .
FETCH Clause specifies when processing OFFSET Number of rows to return after clause . offset_row_count Can be greater than or equal to 1 The constant , Variable or scalar .
OFFSET Clause is required , and FETCH Clauses are optional . Besides , FIRST and NEXT Synonyms , So they can be used interchangeably .
版权声明
本文为[Wood acridine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210616404858.html
边栏推荐
- 检测技术与原理
- Automatic control (Han min version)
- 电机与拖动(戚金清版)学习整理
- Protected (members modified by protected are visible to this package and its subclasses)
- ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
- MySQL basic madness theory
- Integers have friends interval GCD + double pointer
- Why does the subscript of the array start from 0 instead of 1?
- 6.Reversal
- IO multiplexing of 09 redis
猜你喜欢
电机与拖动(戚金清版)学习整理
Complete example demonstration of creating table to page - joint table query
Pytorch notes - complete code for linear regression & manual or automatic calculation of gradient code comparison
檢測技術與原理
Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
Preparedstatement prevents SQL injection
Mysql database foundation
In depth understanding of the relationship between dncblevel and noise denoising in the paper
Guaba and Computational Geometry
线性代数第一章-行列式
随机推荐
线代第四章-向量组的线性相关
图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi
Delete and truncate
Event listener
Sakura substring thinking
Numpy common function table sorting of data processing
Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()
JDBC operation transaction
The bottom implementation principle of thread - static agent mode
Use of multithreaded executors
Best practices for MySQL storage time
SQL optimization best practices
Contrôle automatique (version Han min)
Understanding and use of tp50, tp90 and tp99
9.Life, the Universe, and Everything
Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
JDBC connection database
Optional best practices
Exception handling: grab and throw model
[leetcode 350] intersection of two arrays II