SQL - Offeset and Fetch Clause

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • SQL - Offset and Fetch Clause
    • SQL - Offeset and Fetc...
    SQL | OFFSET-FETCH Clause
    OFFSET and FETCH Clause are used in conjunction with SELECT and ORDER BY clause
    to provide a means to retrieve a range of records.
    OFFSET
    The OFFSET argument is used to identify the starting point to return rows from a result set.
    Basically, it excludes the first set of records.
    Note:
    OFFSET can only be used with the ORDER BY clause. It cannot be used on its own.
    OFFSET value must be greater than or equal to zero. It cannot be negative, or else return error.
    oFFSET- 12 VERSION and above
    Syntax:
    SELECT column_name(s)
    FROM table_name
    WHERE condition
    ORDER BY column_name
    OFFSET rows_to_skip ROWS;
    FETCH
    The FETCH argument is used to return a set of number of rows.
    FETCH can’t be used itself, it is used in conjunction with OFFSET.
    Syntax:
    SELECT column_name(s)
    FROM table_name
    WHERE condition
    ORDER BY column_name
    OFFSET rows_to_skip
    FETCH NEXT number_of_rows ROWS ONLY;
    EXAMPLE:-
    --after 10000 5000
    select * from Person.Person
    order by BusinessEntityID
    offset 10000 rows
    -- fetch
    select * from Person.Person
    order by BusinessEntityID
    offset 10000 rows
    fetch next 5000 rows only
    SQL(STRUCTURE QUERY LANGUAGE) PLAYLIST
    • SQL Theory Tutorial(ST...
    #Subscribe the #Channel #Link :- #bansodetechsoluiotn #ajupgrading czcams.com/users/AjUpgrading...
    IF any #Query or #Doubt #DM on #Instagram :- #bansode_ajay_2102
    bansode_aja...
    LinkedIn Profile
    / aj-upgrading-bansode-t...
    Link for slides, code samples, and text version of the video #blogger
    bansodetechsolution.blogspot.com

Komentáře •