Ordering
Order by
- Kotlin
- SQL
val alphabetical = ShopTable
.orderBy(ShopTable.name)
.perform(db)
val reverseAlphabetical = ShopTable
.orderBy(ShopTable.name.desc())
.perform(db)
SELECT T0."id" c0
, T0."name" c1
, T0."address" c2
, T0."established" c3
FROM "Shop" T0
ORDER BY T0."name" ASC
SELECT T0."id" c0
, T0."name" c1
, T0."address" c2
, T0."established" c3
FROM "Shop" T0
ORDER BY T0."name" DESC
Nulls first and last
- Kotlin
- SQL
ShopTable
.orderBy(ShopTable.established.desc().nullsLast())
.perform(db)
ShopTable
.orderBy(ShopTable.established.asc().nullsFirst())
.perform(db)
SELECT T0."id" c0
, T0."name" c1
, T0."address" c2
, T0."established" c3
FROM "Shop" T0
ORDER BY T0."established" DESC NULLS LAST
SELECT T0."id" c0
, T0."name" c1
, T0."address" c2
, T0."established" c3
FROM "Shop" T0
ORDER BY T0."established" ASC NULLS FIRST
Compound order
- Kotlin
- SQL
ShopTable
.orderBy(
ShopTable.established.desc().nullsLast(),
ShopTable.name
)
.perform(db)
SELECT T0."id" c0
, T0."name" c1
, T0."address" c2
, T0."established" c3
FROM "Shop" T0
ORDER BY T0."established" DESC NULLS LAST, T0."name" ASC