当前位置:网站首页>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
边栏推荐
- Opening and using Alibaba cloud object storage OSS
- Idea optimization strategy
- Kinect2 for Unity3D——AvatarDemo学习
- 2022 preparation for autumn recruitment 10W word interview sketch PDF version, with operating system and computer network interview questions
- Useful resources for ns2
- 利用 Fastjson json (简单粗暴版)
- 2022备战秋招10W字面试小抄pdf版,附操作系统、计算机网络面试题
- 电磁场学习笔记-矢量分析和场论基础
- Rs2022/ cloud detection: semi supervised cloud detection in satellite images by considering the
- Performance analysis of continuous time system (1) - performance index and first and second order analysis of control system
猜你喜欢

MySQL learning notes (2) -- stored procedures and stored functions

一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?

Sword finger offer17- print from 1 to the maximum n digits - Analog

mysql学习笔记(1)——变量

I'm afraid I won't use the JMeter interface testing tool if I accept this practical case

Unity-显示Kinect深度数据

Self control principle learning notes - system stability analysis (1) - BIBO stability and Routh criterion

Basic use of Nacos (1) - getting started

Selenium automated test interview questions family bucket

2022 Ningde Vocational College Teachers' practical teaching ability improvement training - network construction and management
随机推荐
web UI 自动化测试:Selenium 语法详解 史上最全
Double insurance for line breaking
v-if,v-else,v-for
MySQL学习笔记(2)——存储过程与存储函数
Webmagic+selenium+chromedriver+jdbc垂直抓取数据。
Matrix of shell programming -- it's cute and cool
During the interface test, connect to the database and back up, restore and verify the data source
又有一个Repeater的例子
I'm afraid I won't use the JMeter interface testing tool if I accept this practical case
每日一题(02):倒置字符串
idea优化小攻略
200行代码快速入门文档型数据库MonogoDB
How to generate random numbers with standard distribution or Gaussian distribution
NPM basic use
Kinect for Unity3D——BackgroundRemovalDemo学习
There is another example of repeater
WSN journal indexed by SCI
连续时间系统的性能分析(1)-控制系统性能指标及一二阶分析
sql 时间处理(SQL SERVER\ORACLE)
Some advice for NS2 beginner.