How can i get first or last 3 records from select statement

using select statements in x++ how can i get first or last 3 records

As you can see in Select Statement Syntax, there is firstOnly10, but not firstOnly3 or anything like that. Therefore ask the select to fetch first ten records and take only three. For example:

int i;
while select firstOnly10 myTable
    order by SomeField // "first" has no meaning without ordering
{
    // do something with the record
    
    i++;
    
    if (i == 3)
    {
        break;
    }
}

Thanks!
This worked out…