mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Special Math Operators as a postgres til.
This commit is contained in:
35
postgres/special-math-operators.md
Normal file
35
postgres/special-math-operators.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Special Math Operators
|
||||
|
||||
Postgres has all the mathematical operators you might expect in any
|
||||
programming language (e.g. `+`,`-`,`*`,`/`,`%`). It also has a few extras
|
||||
that you might not be expecting.
|
||||
|
||||
Factorial Operator:
|
||||
|
||||
```sql
|
||||
> select 5!;
|
||||
?column?
|
||||
----------
|
||||
120
|
||||
(1 row)
|
||||
```
|
||||
|
||||
Square Root Operator:
|
||||
|
||||
```sql
|
||||
> select |/81;
|
||||
?column?
|
||||
----------
|
||||
9
|
||||
(1 row)
|
||||
```
|
||||
|
||||
Absolute Value Operator:
|
||||
|
||||
```sql
|
||||
> select @ -23.4;
|
||||
?column?
|
||||
----------
|
||||
23.4
|
||||
(1 row)
|
||||
```
|
||||
Reference in New Issue
Block a user