Overview of Numeric Functions
Here are some of the numeric functions we might use quite often.
abs
- always return positive number
round
- rounds off to specified precision
ceil
, floor
- always return integer.
greatest
sum
, avg
min
, max
random
pow
, sqrt
Some of the functions highlighted are aggregate functions, eg: sum
, avg
, min
, max
etc.
The sql extension is already loaded. To reload it, use:
%reload_ext sql
env: DATABASE_URL=postgresql://itversity_retail_user:retail_password@localhost:5432/itversity_retail_db
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
order_revenue_avg |
193.32666666666668 |
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
10 rows affected.
order_item_order_id |
order_revenue_sum |
1 |
299.98 |
2 |
579.98 |
4 |
699.85 |
5 |
1129.8600000000001 |
7 |
579.9200000000001 |
8 |
729.8399999999999 |
9 |
599.96 |
10 |
651.9200000000001 |
11 |
919.79 |
12 |
1299.8700000000001 |
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
10 rows affected.
order_item_order_id |
order_revenue_avg |
1 |
299.98 |
2 |
579.98 |
4 |
699.85 |
5 |
1129.86 |
7 |
579.92 |
8 |
729.84 |
9 |
599.96 |
10 |
651.92 |
11 |
919.79 |
12 |
1299.87 |
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
10 rows affected.
order_item_order_id |
order_revenue_sum |
order_item_subtotal_min |
order_item_subtotal_max |
1 |
299.98 |
299.98 |
299.98 |
2 |
579.98 |
129.99 |
250.0 |
4 |
699.85 |
49.98 |
299.95 |
5 |
1129.86 |
99.96 |
299.98 |
7 |
579.92 |
79.95 |
299.98 |
8 |
729.84 |
50.0 |
299.95 |
9 |
599.96 |
199.98 |
199.99 |
10 |
651.92 |
21.99 |
199.99 |
11 |
919.79 |
49.98 |
399.96 |
12 |
1299.87 |
100.0 |
499.95 |
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
random |
0.03222073158160299 |
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.
* postgresql://itversity_retail_user:***@localhost:5432/itversity_retail_db
1 rows affected.