head command
Note
To see which AWS data source integrations support this PPL command, see Commands.
Use the head
command to return the first N number of specified
results after an optional offset in search order.
Syntax
Use the following syntax:
head [<size>] [from <offset>]
<size>
-
Optional integer.
-
The number of results to return.
-
Default: 10
<offset>
-
Integer after optional
from
. -
The number of results to skip.
-
Default: 0
Example 1: Get first 10 results
This example shows how to retrieve a maximum of 10 results from the accounts index.
PPL query:
os> source=accounts | fields firstname, age | head; fetched rows / total rows = 4/4 +-------------+-------+ | firstname | age | |-------------+-------| | Jane | 32 | | John | 36 | | Jorge | 28 | | Juan | 33 | +-------------+-------+
Example 2: Get first N results
The example shows the first N results from the accounts index.
PPL query:
os> source=accounts | fields firstname, age | head 3; fetched rows / total rows = 3/3 +-------------+-------+ | firstname | age | |-------------+-------| | Jane | 32 | | John | 36 | | Jorge | 28 | +-------------+-------+
Example 3: Get first N results after offset M
This example shows how to retrieve the first N results after skipping M results from the accounts index.
PPL query:
os> source=accounts | fields firstname, age | head 3 from 1; fetched rows / total rows = 3/3 +-------------+-------+ | firstname | age | |-------------+-------| | John | 36 | | Jorge | 28 | | Juan | 33 | +-------------+-------+