From 0e7dfeeda5568efde0c7fbb46dadd0d713d7ccfe Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sat, 11 Jul 2015 08:28:38 -0500 Subject: [PATCH] Add Special Math Operators as a postgres til. --- README.md | 1 + postgres/special-math-operators.md | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 postgres/special-math-operators.md diff --git a/README.md b/README.md index ffd760a..5405cbc 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/postgres/special-math-operators.md b/postgres/special-math-operators.md new file mode 100644 index 0000000..2a091f1 --- /dev/null +++ b/postgres/special-math-operators.md @@ -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) +```