SlideShare a Scribd company logo
A D V A N C E D A T A B A S E S Y S T E M
Functions (Built-In)
Gonzales, Khurt Dhan V.
Lledo, Denise Claire O.
Macellones, Angelo F.
O V E R V I E W
• Numeric functions
• String functions
• Date functions
• Calculating Dates and Times
• The IFNULL and COALESCE functions
• IF functions
• Case operator
What is Built-in
Functions?
T Y P E S O F S Q L B U I L T - I N F U N C T I O N S
1.Numeric functions
2.String functions
3.Date functions
NUMERIC
FUNCTIONS
N U M E R I C F U N C T I O N S
• ABS
• ROUND
• CEIL
• FLOOR
• MOD
• POWER
• SQRT
• GREATEST
• LEAST
• RAND
A B S
S Y N T A X :
E X A M P L E :
SELECT ABS (number);
SELECT ABS (-15);
The ABS() function returns the absolute value of a number.
R O U N D
S Y N T A X :
E X A M P L E :
SELECT ROUND (number, decimal, operations);
SELECT ROUND (123.4567, 2);
The ROUND() function rounds a number to a specified
number of decimal places.
C E I L
S Y N T A X :
E X A M P L E :
SELECT CEIL (number);
SELECT CEIL (6.2);
SELECT CEILING (number);
SELECT CEILING (6.2);
The CEILING() function returns the smallest integer value
that is larger than or equal to a number.
F L O O R
S Y N T A X :
E X A M P L E :
SELECT FLOOR (number);
SELECT FLOOR (5.8);
The FLOOR() function returns the largest integer value that
is smaller than or equal to a number.
M O D
S Y N T A X :
E X A M P L E :
SELECT MOD (dividend, divisor);
SELECT MOD (10, 3);
MOD() is a mathematical function that calculates the
remainder of the division of two numbers.
P O W E R
S Y N T A X :
E X A M P L E :
SELECT POWER (number, power);
SELECT POWER (2, 3);
The POWER() function returns the value of a number raised
to the power of another number.
S Q R T
S Y N T A X :
E X A M P L E :
SELECT SQRT (number);
SELECT SQRT (16);
The SQRT() function returns the square root of a number.
G R E A T E S T
S Y N T A X :
E X A M P L E :
SELECT GREATEST (column 1, column 2,...);
SELECT GREATEST (10, 20, 5, 30, 15);
The GREATEST() it returns the greatest value in a list of
expressions
L E A S T
S Y N T A X :
E X A M P L E :
SELECT LEAST (column 1, column 2,...);
SELECT LEAST (10, 20, 5, 30, 15);
The LEAST() it returns the smallest value in a list of
expressions.
R A N D
S Y N T A X :
E X A M P L E :
SELECT RAND ();
SELECT RAND ();
The RAND() function returns a random number between 0
(inclusive) and 1 (exclusive).
STRING
FUNCTIONS
S T R I N G F U N C T I O N S
• CHAR_LENGTH
• CONCAT
• UPPER | UCASE
• LOWER | LCASE
• SUBSTRING | SUBSTR
• TRIM
• REPLACE
• REVERSE
• LEFT | RIGHT
C H A R _ L E N G T H
S Y N T A X :
E X A M P L E :
SELECT CHAR_LENGTH ();
SELECT CHAR_LENGTH (“Functions”);
The CHAR_LENGTH() function return the length of a string (in characters).
Note: This function is equal to the CHARACTER_LENGTH() function.
C O N C A T
S Y N T A X :
E X A M P L E :
SELECT CONCAT ();
SELECT CONCAT (“Sql”, “is”, “fun!”) AS ConcatenatedString ;
The CONCAT() function adds two or more strings together.
L E N G T H
S Y N T A X :
E X A M P L E :
SELECT LENGTH ();
SELECT LENGTH ();
The LENGTH() is used to find the length of a word.
U P P E R | U C A S E
S Y N T A X :
E X A M P L E :
SELECT UPPER ();
SELECT UPPER ();
The UPPER() function converts a string to upper-case.
L O W E R | L C A S E
S Y N T A X :
E X A M P L E :
SELECT LOWER ();
SELECT LOWER ();
The LOWER() function converts a string to lower-case.
S U B S T R I N G | S U B S T R
S Y N T A X :
E X A M P L E :
SELECT SUBSTRING(string, start, length);
SELECT SUBSTRING (“Hello, World!”, 1, 4) AS ExtractString;
The SUBSTRING() function extracts some characters from a
string.
T R I M
S Y N T A X :
E X A M P L E :
SELECT TRIM();
SELECT TRIM (' Hello, World! ') AS TrimmedString;
The TRIM() is used to cut the given symbol from the string
R E P L A C E
S Y N T A X :
E X A M P L E :
SELECT REPLACE ();
SELECT REPLACE("Hello, Chris!", "Chris", "John");
The REPLACE() function replaces all occurrences of a
substring within a string, with a new substring.
R E V E R S E
S Y N T A X :
E X A M P L E :
SELECT REVERSE ();
SELECT REVERSE (“Hello, everyone”);
The REVERSE() function reverses a string and returns the
result.
L E F T
S Y N T A X :
E X A M P L E :
SELECT LEFT (string, number_of_char);
SELECT LEFT (“SQL is fun”, 3) AS ExtractString;
The LEFT() function extracts a number of characters from a
string (starting from left).
R I G H T
S Y N T A X :
E X A M P L E :
SELECT RIGHT (string, number_of_char);
SELECT RIGHT(“SQL is fun”, 3) AS ExtractString;
The RIGHT() function extracts a number of characters from a
string (starting from right).
DATE
FUNCTIONS
D A T E F U N C T I O N S
CURRENT_DATE
Returns current date
CURRENT_TIME
Returns current time
CURRENT_TIMESTAMP
Returns current timestamp
T I M E S T A M P
2024-09-17 10:30:00
2024-09-17 10:30:00
D A T E T I M E
D A T E A N D T I M E F U N C T I O N S
DATE
Extracts the date part
from a datetime
expression (timestamp)
TIME
Extracts the time part
from a datetime
expression (timestamp)
D A T E
2024-09-17
2024 1
7
Y E A R D A Y
09
M O N T H
T I M E
12:00:00
12 00
H O U R S E C O N D
00
M I N U T E
CALCULATING
DATES AND
TIMES
D A T E _ A D D
The DATE_ADD() function adds a time/date interval to a date
and then returns the date.
S Y N T A X :
SELECT DATEADD(date, INTERVAL value addunit);
D A T E _ S U B
S Y N T A X :
SELECT DATE_SUB(date, INTERVAL value interval);
The DATE_SUB() function subtracts a time/date interval from a date
and then returns the date.
D A T E D I F F
S Y N T A X :
SELECT DATEDIFF(date1, date2);
The DATEDIFF() function returns the number of days between two
date values.
THE IF NULL
AND COALESCE
FUNCTIONS
I F N U L L
S Y N T A X :
IFNULL(expression, alt_value);
The IFNULL() function lets you return an alternative value if an
expression is NULL:
C O A L E S C E
S Y N T A X :
COALESCE(val1, val2, ...., val_n);
The COALESCE() function returns the first non-null value in a list.
T H E I F F U N C T I O N
S Y N T A X :
IF(condition, value_if_true, value_if_false);
The IF() function returns a value if a condition is TRUE, or another
value if a condition is FALSE.
T H E C A S E O P E R A T O R
The CASE statement goes through conditions and return a value when the first
condition is met. So, once a condition is true, it will stop reading and return the
result.
If no conditions are true, it will return the value in the ELSE clause.
If there is no ELSE part and no conditions are true, it returns NULL.
S Y N T A X :
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
WHEN conditionN THEN resultN
ELSE result
END;
Thank you!
Gonzales, Khurt Dhan V.
Lledo, Denise Claire O.
Macellones, Angelo F.

More Related Content

PDF
Oracle sql functions
PPTX
Math, Text, Date Functions of MySQL for Class-12 CBSE
PPT
Oracle sql ppt2
PPTX
Structured query language functions
PPT
Intro to tsql unit 10
PPS
Let Us Learn Lambda Using C# 3.0
PDF
Postgresql 9.3 overview
PDF
dbms.pdf
Oracle sql functions
Math, Text, Date Functions of MySQL for Class-12 CBSE
Oracle sql ppt2
Structured query language functions
Intro to tsql unit 10
Let Us Learn Lambda Using C# 3.0
Postgresql 9.3 overview
dbms.pdf

Similar to Built-Functions in MySqll (Advance Database System) (20)

PDF
TI1220 Lecture 6: First-class Functions
PPT
ODP
PPTX
MS Sql Server: Doing Calculations With Functions
PPTX
MS SQLSERVER:Doing Calculations With Functions
PPTX
MS SQL SERVER: Doing Calculations With Functions
PPT
Sql operators & functions 3
PPTX
L25-L26-Parameter passing techniques.pptx
ODP
Mysql1
PPTX
Bsc cs i pic u-4 function, storage class and array and strings
DOCX
Built-in Functions in SQL | Numeric Functions
PPTX
Diploma ii cfpc u-4 function, storage class and array and strings
PDF
Data structures stacks
DOCX
Functions Practice Sheet.docx
PDF
Excel Tutorials - Random Value Selection from a List
PDF
Excel.useful fns
PPTX
Lecture 02: Preliminaries of Data structure
PDF
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
PDF
Functions torage class and array and strings-
TI1220 Lecture 6: First-class Functions
MS Sql Server: Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With Functions
MS SQL SERVER: Doing Calculations With Functions
Sql operators & functions 3
L25-L26-Parameter passing techniques.pptx
Mysql1
Bsc cs i pic u-4 function, storage class and array and strings
Built-in Functions in SQL | Numeric Functions
Diploma ii cfpc u-4 function, storage class and array and strings
Data structures stacks
Functions Practice Sheet.docx
Excel Tutorials - Random Value Selection from a List
Excel.useful fns
Lecture 02: Preliminaries of Data structure
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Functions torage class and array and strings-
Ad

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MYSQL Presentation for SQL database connectivity
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Ad

Built-Functions in MySqll (Advance Database System)

  • 1. A D V A N C E D A T A B A S E S Y S T E M Functions (Built-In) Gonzales, Khurt Dhan V. Lledo, Denise Claire O. Macellones, Angelo F.
  • 2. O V E R V I E W • Numeric functions • String functions • Date functions • Calculating Dates and Times • The IFNULL and COALESCE functions • IF functions • Case operator
  • 4. T Y P E S O F S Q L B U I L T - I N F U N C T I O N S 1.Numeric functions 2.String functions 3.Date functions
  • 6. N U M E R I C F U N C T I O N S • ABS • ROUND • CEIL • FLOOR • MOD • POWER • SQRT • GREATEST • LEAST • RAND
  • 7. A B S S Y N T A X : E X A M P L E : SELECT ABS (number); SELECT ABS (-15); The ABS() function returns the absolute value of a number.
  • 8. R O U N D S Y N T A X : E X A M P L E : SELECT ROUND (number, decimal, operations); SELECT ROUND (123.4567, 2); The ROUND() function rounds a number to a specified number of decimal places.
  • 9. C E I L S Y N T A X : E X A M P L E : SELECT CEIL (number); SELECT CEIL (6.2); SELECT CEILING (number); SELECT CEILING (6.2); The CEILING() function returns the smallest integer value that is larger than or equal to a number.
  • 10. F L O O R S Y N T A X : E X A M P L E : SELECT FLOOR (number); SELECT FLOOR (5.8); The FLOOR() function returns the largest integer value that is smaller than or equal to a number.
  • 11. M O D S Y N T A X : E X A M P L E : SELECT MOD (dividend, divisor); SELECT MOD (10, 3); MOD() is a mathematical function that calculates the remainder of the division of two numbers.
  • 12. P O W E R S Y N T A X : E X A M P L E : SELECT POWER (number, power); SELECT POWER (2, 3); The POWER() function returns the value of a number raised to the power of another number.
  • 13. S Q R T S Y N T A X : E X A M P L E : SELECT SQRT (number); SELECT SQRT (16); The SQRT() function returns the square root of a number.
  • 14. G R E A T E S T S Y N T A X : E X A M P L E : SELECT GREATEST (column 1, column 2,...); SELECT GREATEST (10, 20, 5, 30, 15); The GREATEST() it returns the greatest value in a list of expressions
  • 15. L E A S T S Y N T A X : E X A M P L E : SELECT LEAST (column 1, column 2,...); SELECT LEAST (10, 20, 5, 30, 15); The LEAST() it returns the smallest value in a list of expressions.
  • 16. R A N D S Y N T A X : E X A M P L E : SELECT RAND (); SELECT RAND (); The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive).
  • 18. S T R I N G F U N C T I O N S • CHAR_LENGTH • CONCAT • UPPER | UCASE • LOWER | LCASE • SUBSTRING | SUBSTR • TRIM • REPLACE • REVERSE • LEFT | RIGHT
  • 19. C H A R _ L E N G T H S Y N T A X : E X A M P L E : SELECT CHAR_LENGTH (); SELECT CHAR_LENGTH (“Functions”); The CHAR_LENGTH() function return the length of a string (in characters). Note: This function is equal to the CHARACTER_LENGTH() function.
  • 20. C O N C A T S Y N T A X : E X A M P L E : SELECT CONCAT (); SELECT CONCAT (“Sql”, “is”, “fun!”) AS ConcatenatedString ; The CONCAT() function adds two or more strings together.
  • 21. L E N G T H S Y N T A X : E X A M P L E : SELECT LENGTH (); SELECT LENGTH (); The LENGTH() is used to find the length of a word.
  • 22. U P P E R | U C A S E S Y N T A X : E X A M P L E : SELECT UPPER (); SELECT UPPER (); The UPPER() function converts a string to upper-case.
  • 23. L O W E R | L C A S E S Y N T A X : E X A M P L E : SELECT LOWER (); SELECT LOWER (); The LOWER() function converts a string to lower-case.
  • 24. S U B S T R I N G | S U B S T R S Y N T A X : E X A M P L E : SELECT SUBSTRING(string, start, length); SELECT SUBSTRING (“Hello, World!”, 1, 4) AS ExtractString; The SUBSTRING() function extracts some characters from a string.
  • 25. T R I M S Y N T A X : E X A M P L E : SELECT TRIM(); SELECT TRIM (' Hello, World! ') AS TrimmedString; The TRIM() is used to cut the given symbol from the string
  • 26. R E P L A C E S Y N T A X : E X A M P L E : SELECT REPLACE (); SELECT REPLACE("Hello, Chris!", "Chris", "John"); The REPLACE() function replaces all occurrences of a substring within a string, with a new substring.
  • 27. R E V E R S E S Y N T A X : E X A M P L E : SELECT REVERSE (); SELECT REVERSE (“Hello, everyone”); The REVERSE() function reverses a string and returns the result.
  • 28. L E F T S Y N T A X : E X A M P L E : SELECT LEFT (string, number_of_char); SELECT LEFT (“SQL is fun”, 3) AS ExtractString; The LEFT() function extracts a number of characters from a string (starting from left).
  • 29. R I G H T S Y N T A X : E X A M P L E : SELECT RIGHT (string, number_of_char); SELECT RIGHT(“SQL is fun”, 3) AS ExtractString; The RIGHT() function extracts a number of characters from a string (starting from right).
  • 31. D A T E F U N C T I O N S CURRENT_DATE Returns current date CURRENT_TIME Returns current time CURRENT_TIMESTAMP Returns current timestamp
  • 32. T I M E S T A M P 2024-09-17 10:30:00 2024-09-17 10:30:00 D A T E T I M E
  • 33. D A T E A N D T I M E F U N C T I O N S DATE Extracts the date part from a datetime expression (timestamp) TIME Extracts the time part from a datetime expression (timestamp)
  • 34. D A T E 2024-09-17 2024 1 7 Y E A R D A Y 09 M O N T H
  • 35. T I M E 12:00:00 12 00 H O U R S E C O N D 00 M I N U T E
  • 37. D A T E _ A D D The DATE_ADD() function adds a time/date interval to a date and then returns the date. S Y N T A X : SELECT DATEADD(date, INTERVAL value addunit);
  • 38. D A T E _ S U B S Y N T A X : SELECT DATE_SUB(date, INTERVAL value interval); The DATE_SUB() function subtracts a time/date interval from a date and then returns the date.
  • 39. D A T E D I F F S Y N T A X : SELECT DATEDIFF(date1, date2); The DATEDIFF() function returns the number of days between two date values.
  • 40. THE IF NULL AND COALESCE FUNCTIONS
  • 41. I F N U L L S Y N T A X : IFNULL(expression, alt_value); The IFNULL() function lets you return an alternative value if an expression is NULL:
  • 42. C O A L E S C E S Y N T A X : COALESCE(val1, val2, ...., val_n); The COALESCE() function returns the first non-null value in a list.
  • 43. T H E I F F U N C T I O N S Y N T A X : IF(condition, value_if_true, value_if_false); The IF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.
  • 44. T H E C A S E O P E R A T O R The CASE statement goes through conditions and return a value when the first condition is met. So, once a condition is true, it will stop reading and return the result. If no conditions are true, it will return the value in the ELSE clause. If there is no ELSE part and no conditions are true, it returns NULL.
  • 45. S Y N T A X : CASE WHEN condition1 THEN result1 WHEN condition2 THEN result2 WHEN conditionN THEN resultN ELSE result END;
  • 46. Thank you! Gonzales, Khurt Dhan V. Lledo, Denise Claire O. Macellones, Angelo F.