Skip to content

Commit 70dab1b

Browse files
add G-3183, closes #202
1 parent 74726da commit 70dab1b

File tree

1 file changed

+34
-0
lines changed
  • docs/4-language-usage/3-dml-and-sql/1-general

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# G-3183: Always specify column aliases instead of expressions in GROUP BY clauses.
2+
3+
!!! tip "Minor"
4+
Readability, Maintainability
5+
6+
## Restriction
7+
8+
Oracle Database 23c
9+
10+
## Reason
11+
12+
Starting with Oracle Database 23c, it is possible to use a column alias in the `group by` clause instead of repeating the expression used in the `select` list.
13+
14+
Unless you use `rollup`, `cube` or `grouping sets`, it is not necessary to use expressions in the `group by` clause.
15+
16+
## Example (bad)
17+
18+
``` sql
19+
select lower(job_id) as job
20+
,sum(salary) as sum_salary
21+
from employees
22+
group by lower(job_id)
23+
order by job;
24+
```
25+
26+
## Example (good)
27+
28+
``` sql
29+
select lower(job_id) as job
30+
,sum(salary) as sum_salary
31+
from employees
32+
group by job
33+
order by job;
34+
```

0 commit comments

Comments
 (0)