OrderBy & Limit
OrderBy
- Function
This function sorts result sets based on one or more columns.
- Syntax Format
1 2 3 4 5 6
SELECT [ ALL | DISTINCT ] { * | projectItem [, projectItem ]* } FROM tableExpression [ WHERE booleanExpression ] [ GROUP BY { groupItem [, groupItem ]* } ] [ ORDER BY Itemtime|Item [ASC | DESC] ]
- Precautions
By default, ORDER BY sorts data in ascending order. ASC: indicates the ascending order, and DESC the descending order.
- Example
Sort data in ascending order on the time attribute.
1 2 3
SELECT * FROM Orders ORDER BY orderTime;
Limit
- Function
This clause is used to constrain the number of rows returned.
- Precautions
This clause is used in conjunction with ORDER BY to ensure that the results are deterministic.
- Example
1 2 3 4
SELECT * FROM Orders ORDER BY orderTime LIMIT 3;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot