Skip to content

Commit 66ae8c1

Browse files
committed
some additions for the review
1 parent 574e97d commit 66ae8c1

File tree

2 files changed

+21
-54
lines changed

2 files changed

+21
-54
lines changed

cds/assets/cql/select.drawio.svg

Lines changed: 1 addition & 37 deletions
Loading

cds/cql.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ SELECT from Authors { name, dateOfDeath }
557557
where dateOfDeath is not null
558558
```
559559

560+
[Learn more about `null` handling](./cxl#operators-xpr){.learn-more}
561+
562+
560563
## Group by and having {#group-by}
561564

562565
`group by` aggregates rows sharing the same values in the specified elements into summary rows. Aggregate functions like `count`, `sum`, `avg`, `min`, and `max` are then applied per group.
@@ -612,7 +615,11 @@ SELECT from Books {
612615

613616
The `order by` clause sorts the result set by one or more [ordering terms](#ordering-term). The default order is ascending (`asc`); use `desc` to reverse it.
614617

615-
### Ascending and Descending
618+
### Ordering Term {#ordering-term}
619+
620+
![](./assets/cql/ordering-term.drawio.svg?raw)
621+
622+
616623

617624
For example, to list books ordered by price from lowest to highest:
618625

@@ -628,15 +635,25 @@ SELECT from Books { title, price }
628635
order by price desc
629636
```
630637

631-
### Ordering by Multiple Elements
632-
633638
You can specify several ordering terms, separated by commas. The result is sorted by the first term, then by the second for ties, and so on:
634639

635640
```cds live
636641
SELECT from Books { title, author.name as author, price }
637642
order by author asc, price desc
638643
```
639644

645+
:::info `null` handling
646+
647+
By default, the position of `null` values in the sort order is database-specific. Use `nulls first` or `nulls last` to make this explicit:
648+
649+
```cds live
650+
SELECT from Authors { name, dateOfDeath }
651+
order by dateOfDeath nulls last
652+
```
653+
654+
:::
655+
656+
640657
### Name Resolution — Using Select List Aliases
641658

642659
In `order by`, identifiers are resolved against the **select list first**, then against the query source. This means you can order by an alias defined in the projection:
@@ -661,15 +678,6 @@ SELECT from Books { title, price }
661678
order by author.name asc, title asc
662679
```
663680

664-
### Null Handling
665-
666-
By default, the position of `null` values in the sort order is database-specific. Use `nulls first` or `nulls last` to make this explicit:
667-
668-
```cds live
669-
SELECT from Authors { name, dateOfDeath }
670-
order by dateOfDeath nulls last
671-
```
672-
673681
## Limit and Offset
674682

675683
`limit` restricts the number of rows returned. `offset` skips a given number of rows before returning results. Together they enable pagination.
@@ -756,8 +764,3 @@ extend BookReviews with columns {
756764
book : Association to Books on book.ID = bookID
757765
};
758766
```
759-
760-
761-
## Ordering Term {#ordering-term}
762-
763-
![](./assets/cql/ordering-term.drawio.svg?raw)

0 commit comments

Comments
 (0)