tencent cloud

Cloud Log Service

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Features
Available Regions
Limits
Concepts
Service Regions and Service Providers
Purchase Guide
Billing Overview
Product Pricing
Pay-as-You-Go
Billing
Cleaning up CLS resources
Cost Optimization
FAQs
Getting Started
Getting Started in 1 Minute
Getting Started Guide
Quickly Trying out CLS with Demo
Operation Guide
Resource Management
Permission Management
Log Collection
Metric Collection
Log Storage
Metric Storage
Search and Analysis (Log Topic)
Search and Analysis (Metric Topic)
Dashboard
Data Processing documents
Shipping and Consumption
Monitoring Alarm
Cloud Insight
Independent DataSight console
Historical Documentation
Practical Tutorial
Log Collection
Search and Analysis
Dashboard
Monitoring Alarm
Shipping and Consumption
Cost Optimization
Developer Guide
Embedding CLS Console
CLS Connection to Grafana
API Documentation
History
Introduction
API Category
Making API Requests
Topic Management APIs
Log Set Management APIs
Index APIs
Topic Partition APIs
Machine Group APIs
Collection Configuration APIs
Log APIs
Metric APIs
Alarm Policy APIs
Data Processing APIs
Kafka Protocol Consumption APIs
CKafka Shipping Task APIs
Kafka Data Subscription APIs
COS Shipping Task APIs
SCF Delivery Task APIs
Scheduled SQL Analysis APIs
COS Data Import Task APIs
Data Types
Error Codes
FAQs
Health Check
Collection
Log Search
Others
CLS Service Level Agreement
CLS Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

ORDER BY Syntax

PDF
Focus Mode
Font Size
Last updated: 2024-01-20 17:25:15
The ORDER BY syntax is used to sort analysis results by a specified column name.

Syntax Format

ORDER BY column name [DESC | ASC]
Note:
You can specify multiple column names to sort analysis results in different sorting modes, for example, ORDER BY column name 1[DESC | ASC], column name 2[DESC | ASC].
If you do not specify the keyword DESC or ASC, the system sorts the analysis results in ascending order.
If the target column for sorting contains duplicated values, the sorting result may be different each time. If you want the sorting result to remain the same in each sorting, you can specify multiple columns for sorting.
Parameter descriptions:
Parameter
Description
Column name
Group data by log field name or aggregate function calculation result column.
DESC
Sort data in descending order.
ASC
Sort data in ascending order.

Syntax Example

Count the number of requests in different states and sort them in descending order by the number of requests:
* | SELECT status, count(*) AS pv GROUP BY status ORDER BY pv DESC
Calculate the average request time for each server and sort them in ascending order:
* | SELECT remote_addr, avg(request_time) as request_time group by remote_addr order by request_time ASC LIMIT 10


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback