当前位置:网站首页>SQL Server top keyword usage
SQL Server top keyword usage
2022-07-27 19:20:00 【The bearer of dark cuisine】
Sometimes it is not necessary to retrieve all the data for query , When we only use some of them , You need some keywords .
MYSQL The key word is limit,SQL server The key word is top.
SQL server top Use of keywords :
# Take out the first three items of data
select top 3 * from table
# Take out the top percent of the data 20
select top 20 percent * from table
# From the query 200 Strip of data 30-100 Data
with t as ( select top 200 row_number() over(order by uuid) r, * from table)
select * from t where r between 30 and 100
# From the query 200 Strip of data 100 Data after
with t as ( select top 200 row_number() over(order by uuid) r, * from table)
select * from t where r >100MYSQL limit Use of keywords
# The meaning is to skip 2 Strip out 1 Data ,limit The back is from 2 Start reading , Read 1 Bar information , That is, read the 3 Data
select * from table limit 2,1;
# The meaning is from 1 strip ( barring ) The data starts to come out 2 Data ,limit It's followed by 2 Data ,offset The back is from 1 Bar start reading , That is, read the 2,3 strip
select * from table limit 2 offset 1;
MYSQL limit Use of keywords
/*Mysql limit offset Example
example 1, Suppose the database table student There is 13 Data .
*/
# Code example :
// sentence 1 and 2 All return to table student Of the 10、11、12、13 That's ok
sentence 1:select * from student limit 9,4
// sentence 2 Medium 4 Said to return to 4 That's ok ,9 Indicates starting at line 10 of the table
sentence 2:slect * from student limit 4 offset 9
example 2, adopt limit and offset Or only through limit Paging function can be realized .
hypothesis numberperpage Indicates the number of items to be displayed on each page ,pagenumber Page number , that Back to page pagenumber page , The number of entries per page is numberperpage Of sql sentence :
Code example :
sentence 3:select * from studnet limit (pagenumber-1)*numberperpage,numberperpage
sentence 4:select * from student limit numberperpage offset (pagenumber-1)*numberperpageOther database related contents
-- If I find out 1000 Bar record , I want to take the first 200~300 Bar record
--oracle:
with t as ( select rownum r, * from surface where rownum<=300 )
select * from t where r>=200
--db2:
with t as ( select row_number() over(order by Field ) r, * from surface fetch frist 300 rows only)
select * from t where r>=200
-- among sqlserver\oracle\db2 Or directly
with t as (select row_number() over(order by Field ) r, * from surface )
select * from t where r between 200 and 300
边栏推荐
- The understanding of string in C.
- SSM integration
- The great idea of NS2
- Unity学习笔记(实现传送带)
- Basic concepts of Nacos and single machine deployment
- What if idea successfully connects to the database without displaying the table
- IDEA连接数据库时区问题,报红Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
- kettle 分列、合并记录
- 图的遍历的定义以及深度优先搜索和广度优先搜索(二)
- 连续时间系统的性能分析(1)-控制系统性能指标及一二阶分析
猜你喜欢

每日一题(02):倒置字符串

Summary of "performance test" of special test

收下这份实操案例,还怕不会用Jmeter接口测试工具

During the interface test, connect to the database and back up, restore and verify the data source

Kinect for unity3d - backgroundremovaldemo learning

Performance analysis of continuous time systems (2) - second order system performance improvement methods PID, PR

Unity-显示Kinect深度数据

What if idea successfully connects to the database without displaying the table

Express get/post/delete... Request

Introduction to assembly language (1)
随机推荐
Using MATLAB to generate graphics for journals and conferences - plot
阿里云对象存储OSS的开通和使用
Unity learning notes - six common functions of object movement
PHP字符串操作
Nodejs template engine EJS
Unity display Kinect depth data
阿里云视频点播服务的开通和使用
Resource for NS2 beginner
Cyclic multi-Variate Function for Self-Supervised Image Denoising by Disentangling Noise from Image
MySQL learning notes (1) -- variables
IDEA成功连接Database但不显示表怎么办
Nacos的基本使用(1)——入门
idea优化小攻略
Using vscode to build u-boot development environment
Browser rendering principle analysis suggestions collection
sql 时间处理(SQL SERVER\ORACLE)
Express get/post/delete... Request
Big enemies, how to correctly choose the intended enterprises in the new testing industry?
PHP string operation
Webmagic+selenium+chromedriver+jdbc垂直抓取数据。