Order By Queries¶
You can sort table results using the order_by() method, which integrates with the query chain.
Basic Sorting¶
Ascending sort (default)¶
Descending sort¶
Sort by Multiple Columns¶
Chaining with Other Operations¶
The order_by() method can be chained with select(), where(), and by():
>>> result = (
table
.select("name", "salary")
.where(Column("salary") > 50000)
.order_by("salary", desc=True)
.execute()
)
Using Column Objects¶
You can use Column objects instead of strings: