1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 23:28:02 +00:00

Add Shorthand Absolute Value Operator as a postgres til

This commit is contained in:
jbranchaud
2020-07-14 19:31:05 -05:00
parent 6691890faa
commit f35e334506
2 changed files with 26 additions and 1 deletions

View File

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