Home Database Mysql Tutorial sql面试题(查看数据中指定几行记录)_MySQL

sql面试题(查看数据中指定几行记录)_MySQL

Jun 01, 2016 pm 01:16 PM
sql database Record

分享一个sql数据库面试题。

问题:

表 table1,主键为 ID,ID为自动编号(ID可能不连续),要求查询第31-40行记录,请问SQL语句怎么写?

实现代码:


--SQL server
select top 10 *
from
(select top 40 * from table1 order by ID) a
order by ID desc
--Oracle
select *
from
(select top 40 * from t order by ID) a
where
rownum>30

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Mar 12, 2024 pm 07:20 PM

Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products?

How to view and manage Linux command history How to view and manage Linux command history Aug 01, 2023 pm 09:17 PM

How to view and manage Linux command history

How to check call history in iPhone and export it? How to check call history in iPhone and export it? Jul 05, 2023 pm 12:54 PM

How to check call history in iPhone and export it?

C# Development Advice: Logging and Monitoring Systems C# Development Advice: Logging and Monitoring Systems Nov 22, 2023 pm 08:30 PM

C# Development Advice: Logging and Monitoring Systems

How to log and monitor Java development projects How to log and monitor Java development projects Nov 03, 2023 am 10:09 AM

How to log and monitor Java development projects

How to view your medication log history in the Health app on iPhone How to view your medication log history in the Health app on iPhone Nov 29, 2023 pm 08:46 PM

How to view your medication log history in the Health app on iPhone

Steps to install SQL Server 2021 Developer Edition on Windows 11 Steps to install SQL Server 2021 Developer Edition on Windows 11 Apr 25, 2023 pm 03:07 PM

Steps to install SQL Server 2021 Developer Edition on Windows 11

How to record running kilometers in keep? Where is the running track recorded? How to record running kilometers in keep? Where is the running track recorded? Mar 12, 2024 am 11:10 AM

How to record running kilometers in keep? Where is the running track recorded?

See all articles