SQL datasets do not preserve the writing order.
The simplest thing to do if order really matters is to use another kind of dataset preserving the order. It can be an S3 bucket, a file, etc.
You can check the dataset type supports ordering by using one instance as the output of a "Sort" recipe. DSS warns you when the dataset type is unable to preserve order.