QuestDB
Get Started
  • Docker
  • Binaries
  • Homebrew
Resources
  • Customers
  • Enterprise
  • Blog
  • Tutorials
  • Videos
Community
  • GitHub
  • Slack
  • Stack Overflow
  • Twitter
Documentation
Get QuestDB
QuestDB
  • Get Started
    • Docker
    • Binaries
    • Homebrew
  • Resources
    • Customers
    • Enterprise
    • Blog
    • Tutorials
    • Videos
  • Community
    • GitHub
    • Slack
    • Stack Overflow
    • Twitter
  • Documentation
  • Introduction
  • Concepts
    • Storage model
    • Designated timestamp
    • SQL extensions
    • Partitions
    • Symbol
    • Indexes
    • Root directory
  • Get Started
    • Docker
    • Binaries
    • Homebrew
    • Create my first database
  • Develop
    • Connect
    • Insert data
    • Query data
    • Authenticate
  • Third-party Tools
    • Grafana
    • Kafka Connect
    • Telegraf
  • Operations
    • Capacity planning
    • Deployment
    • Data retention
    • Health monitoring
  • Reference
    • API
      • REST
      • Postgres
      • InfluxDB
      • Java (embedded)
    • Command-line options
    • Configuration
    • Functions
      • Aggregation
      • Conditional
      • Date and time
      • Meta
      • Numeric
      • Random value generator
      • Row generator
      • Text
      • Timestamp generator
      • Timestamp
    • SQL
      • SQL execution order
      • Data types
      • ALTER TABLE
        • ADD INDEX
        • ADD COLUMN
        • RENAME COLUMN
        • DROP COLUMN
        • DROP PARTITION
      • BACKUP
      • CASE
      • CAST
      • COPY
      • CREATE TABLE
      • DISTINCT
      • EXCEPT & INTERSECT
      • FILL
      • DROP TABLE
      • GROUP BY
      • INSERT
      • JOIN
      • LATEST BY
      • LIMIT
      • ORDER BY
      • RENAME TABLE
      • SAMPLE BY
      • SELECT
      • SHOW
      • TRUNCATE TABLE
      • UNION
      • WHERE
      • WITH
    • Web Console

ORDER BY keyword

Sort the results of a query in ascending or descending order.

Syntax#

Flow chart showing the syntax of the ORDER BY keyword

Default order is ASC. You can omit to order in ascending order.

Examples#

Omitting ASC will default to ascending order
ratings ORDER BY userId;
Ordering in descending order
ratings ORDER BY userId DESC;
Multi-level ordering
ratings ORDER BY userId, rating DESC;

Ressources management#

caution

Ordering data requires holding it in RAM. For large operations, we suggest you check you have sufficient memory to perform the operation.

Previous
« LIMIT keyword
Next
RENAME TABLE keyword »
  • Syntax
  • Examples
  • Ressources management
QuestDB logo

QuestDB is the fastest open source time series database

GitHub logoStar us on GitHub
  • QuestDB
  • Enterprise
  • Customers
  • Careers
  • Community
  • GitHub
  • Slack
  • Stack Overflow
  • Twitter
  • More
  • Documentation
  • Tutorials
  • Blog
  • Videos
  • Roadmap

Copyright © 2021 QuestDB