Content ITV PRO
This is Itvedant Content department
Learning Outcome
5
Use math functions inside SELECT statements
4
Different marketing channels
3
Apply math functions in real-time Instagram database examples
2
Use functions like ROUND(), ABS(), CEIL(), FLOOR(), MOD(), POWER(), SQRT()
1
Understand what Math Built-in Functions are in SQL
Imagine you're working as a Data Analyst at Instagram
You need Math Built-in Functions!
Your manager asks:
In SQL, Math Built-in Functions are used to:
Perform calculations
Modify numeric data
Round numbers
Remove negatives
Perform power & root operations
These are mostly used inside:
SELECT column_name, function_name(column_name)
FROM table_name;
Description of Math Functions
ROUND() – Round Numbers
Rounds number to given decimal places.
Example:
SELECT ROUND(AVG(engagement_score),2) FROM posts;After using ROUND():
2120.79
Actual Avgerage:
2120.78632
CEIL() / CEILING() – Round Up
Rounds number upward.
Now Apply CEIL():
2121
Example:
SELECT CEIL(AVG(engagement_score)) FROM posts;Actual Avgerage:
2120.78632
FLOOR() – Round Down
Rounds number downward.
Example:
SELECT FLOOR(AVG(engagement_score)) FROM posts;Now Apply FLOOR():
2120
Actual Avgerage:
2120.78632
ABS() – Absolute Value
Removes negative sign.
| followers lost |
|---|
| -5 |
| -12 |
| -20 |
| -18 |
| -25 |
Example:
SELECT ABS(followers_lost) FROM posts;| ABS |
|---|
| 5 |
| 12 |
| 20 |
| 18 |
| 25 |
MOD() – Remainder
Returns remainder after division.
Example:
SELECT MOD(likes,10) FROM posts;| Likes |
|---|
| 120 |
| 250 |
| 180 |
| 305 |
| 95 |
| Reminder |
|---|
| 0 |
| 0 |
| 0 |
| 5 |
| 5 |
POWER() – Exponent
Raises number to power.
Example:
SELECT POWER(likes,2) FROM posts;| Likes |
|---|
| 120 |
| 250 |
| 180 |
| 305 |
| 95 |
| likes2 |
|---|
| 14400 |
| 62500 |
| 32400 |
| 93025 |
| 9025 |
when multiplying powers with the same base, add the exponents.
Mathematical Concept:
SQRT() – Square Root
Returns square root.
Mathematical Concept:
Example:
SELECT SQRT(likes) FROM posts;| Likes |
|---|
| 120 |
| 250 |
| 180 |
| 305 |
| 95 |
| SQRT |
|---|
| 10.9545 |
| 15.8114 |
| 13.4164 |
| 17.4642 |
| 9.7468 |
Summary
4
Used heavily in Instagram analytics dashboards
3
Helpful in analytics & reporting
2
Used inside SELECT statements
1
Math Built-in Functions perform numeric calculations
Quiz
Which function returns remainder?
A. MOD()
B. POWER()
C. SQRT()
D. ROUND()
Quiz-Answer
Which function returns remainder?
A. MOD()
B. POWER()
C. SQRT()
D. ROUND()
By Content ITV