Website logo
⌘K
🏠Homepage
👋Introduction
Key Concepts & Architecture
🚀Run Oxla in 2 minutes
🏃‍♂️Run Oxla on S3
🛫Multi-node Deployment
👨‍💻SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
Comment Support
⛓️SQL Mutations
DELETE
UPDATE
🚨Error Handling
🆚Differences Between Oxla vs. PostgreSQL
🔄Understanding Transactions
📈Public Metrics
⚙️Oxla Configuration File
✨Changelog
Docs powered by Archbee
SQL Reference
SQL Clauses

OFFSET

6min

Overview

The OFFSET is a clause that skips some records from the result set.

Syntax

The basic syntax of the OFFSET clause is shown below:

Syntax
SELECT columns
FROM table_name
OFFSET num;


The parameters and arguments from the syntax are:

  • columns: the columns to be fetched.
  • table_name: a table from which the records will be fetched.
  • OFFSET: a clause that will skip a subset of records.
    • num: the number of records to be skipped.

Example

1) Here, we are creating one new table called oxlafunctions using the CREATE TABLE command and inserting some values into the table using the INSERT command:

Create a table
CREATE TABLE oxlafunctions  
(  
    func_name string,   
    func_sub string   
);  

INSERT INTO oxlafunctions   
VALUES
('Numeric', 'ABS'),  
('Numeric', 'CEIL'),  
('String', 'LENGTH'),  
('Numeric', 'SQRT'),  
('Boolean', 'IF'),  
('String', 'STRPOS'),  
('Numeric', 'FLOOR'),  
('String', 'CONCAT'),  
('String', 'LOWER');  


2) To verify that the values have been inserted successfully, retrieve the result set using the command below:

Display the table
SELECT * FROM oxlafunctions;

Output
+------------+------------+
| func_name  | func_sub   |
+------------+------------+
| Numeric    | ABS        |
| Numeric    | CEIL       |
| String     | LENGTH     |
| Numeric    | SQRT       |
| Boolean    | IF         |
| String     | STRPOS     |
| Numeric    | FLOOR      | 
| String     | CONCAT     |
| String     | LOWER      |
+------------+------------+


3) Use the LIMIT clause in conjunction with the OFFSET clause to skip a subset of records:

Select query
SELECT * FROM oxlafunctions
ORDER BY func_name
LIMIT 5 OFFSET 2;


In the above query:

  • The “LIMIT 5” clause is used to fetch only five records.
  • The “OFFSET 2” clause is used to skip the first two records before retrieving the result set of the limit clause.

4) You will get the following output:

Output
+------------+------------+
| func_name  | func_sub   |
+------------+------------+
| Boolean    | IF         |
| Numeric    | SQRT       |
| Numeric    | CEIL       |
| Numeric    | ABS        | 
| Numeric    | FLOOR      |
+------------+------------+




Updated 09 Oct 2023
Did this page help you?
PREVIOUS
LIMIT
NEXT
Set Operations
Docs powered by Archbee
TABLE OF CONTENTS
Overview
Syntax
Example
Docs powered by Archbee

©2023 Oxla