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:
24
postgres/shorthand-absolute-value-operator.md
Normal file
24
postgres/shorthand-absolute-value-operator.md
Normal 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)
|
||||
```
|
||||
Reference in New Issue
Block a user