1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Special Math Operators as a postgres til.

This commit is contained in:
jbranchaud
2015-07-11 08:28:38 -05:00
parent 3ffeb67338
commit 0e7dfeeda5
2 changed files with 36 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
- [Limit Execution Time Of Statements](postgres/limit-execution-time-of-statements.md)
- [List All Columns Of A Specific Type](postgres/list-all-columns-of-a-specific-type.md)
- [Send A Command To psql](postgres/send-a-command-to-psql.md)
- [Special Math Operators](postgres/special-math-operators.md)
- [String Contains Another String](postgres/string-contains-another-string.md)
- [Temporarily Disable Triggers](postgres/temporarily-disable-triggers.md)
- [Temporary Tables](postgres/temporary-tables.md)

View 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)
```