diff --git a/README.md b/README.md index 9cf6faf..c564274 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_936 TILs and counting..._ +_937 TILs and counting..._ --- @@ -512,6 +512,7 @@ _936 TILs and counting..._ - [Set Inclusion With hstore](postgres/set-inclusion-with-hstore.md) - [Set A Seed For The Random Number Generator](postgres/set-a-seed-for-the-random-number-generator.md) - [Sets With The Values Command](postgres/sets-with-the-values-command.md) +- [Shorthand Absolute Value Operator](postgres/shorthand-absolute-value-operator.md) - [Show All Versions Of An Operator](postgres/show-all-versions-of-an-operator.md) - [Sleeping](postgres/sleeping.md) - [Special Math Operators](postgres/special-math-operators.md) diff --git a/postgres/shorthand-absolute-value-operator.md b/postgres/shorthand-absolute-value-operator.md new file mode 100644 index 0000000..fc7365d --- /dev/null +++ b/postgres/shorthand-absolute-value-operator.md @@ -0,0 +1,24 @@ +# Shorthand Absolute Value Operator + +Postgres offers many [math +functions](https://www.postgresql.org/docs/8.0/functions-math.html) including +`abs` for computing the absolute value of a number. + +```sql +> select abs(-1); + abs +----- + 1 +(1 row) +``` + +There is also an absolute value _operator_ -- the `@` symbol. This can be used +to do the same thing. + +```sql +> select @ -1; + ?column? +---------- + 1 +(1 row) +```