2. Math functions: These are those type of functions that accept
numeric values and after performing the required operation,
return numeric values.
MOD(): Returns the remainder of one expression by dividing by another
expression.
e.g. SELECT MOD(11,4) “Modulus”;
POWER()/POW(): Returns the value of one expression raised to the power of
another expression.
e.g. SELECT POWER(3,2) “Power”;
OR, SELECT POW(3,2) “Power”;
3. ROUND(): Returns the value of one expression rounded to an integer. It can
also be used to round an expression to a number of decimal points.
e.g. SELECT ROUND(15.193,1) “Round”;
SIGN(): This function returns sign of a given number.
e.g. SELECT SIGN(-24) “Sign”;
4. SQRT(): Returns the non negative square root of numeric expression.
e.g. SELECT SQRT(25) “Square Root”;
TRUNCATE(): Returns numeric exp1 truncated to exp2 decimal places. If exp2
is 0, then the result will have no decimal point.
e.g. SELECT TRUNCATE(15.79,1) “Truncate”;
5. Text Functions:
UCASE()/UPPER(): Converts to Upper Case.
e.g. SELECT UPPER(‘diya’) “Upper Case”;
OR, SELECT UCASE(‘diya’) “Upper Case”;
LCASE()/LOWER(): Converts to Lower Case.
e.g. SELECT LOWER(‘UDAY’) “Lower Case”;
OR, SELECT LCASE(‘UDAY’) “Lower Case”;
6. MID()/SUBSTRING()/SUBSTR(): Returns a substring starting from the specified
position:
e.g. SELECT MID(‘Quadratically’,5,6);
OR, SELECT SUBSTR(‘Quadratically’,5,6);
OR, SELECT SUBSTRING(‘Quadratically’,-5,4);
LENGTH(): Returns the length of a string in bytes.
e.g. SELECT LENGTH(‘CANDY’) “Length”;
7. LEFT(): Returns the leftmost number of characters as specified.
e.g. SELECT LEFT(‘USS/23/67/09’,6);
RIGHT(): Returns the rightmost number of characters as specified.
e.g. SELECT RIGHT(‘USS/23/67/09’,7);
8. INSTR(): Returns the index of the first occurrence of substring.
e.g. SELECT INSTR(‘CORPORATE FLOOR’, ’O’);
LTRIM(): Removes leading spaces.
e.g. SELECT LTRIM(‘ RDBMS MySQL ‘);
9. RTRIM(): Removes trailing spaces.
e.g. SELECT RTRIM(‘ RDBMS MySQL ‘);
TRIM(): Removes leading and trailing spaces.
e.g. SELECT TRIM(‘ RDBMS MySQL ‘);
10. Date and Time Functions:
NOW(): Returns the time at which the function executes.
e.g. SELECT NOW();
DATE(): Extracts the date part of a date or date-time expression.
e.g. SELECT DATE(‘2020-04-17 01:02:03’);
11. MONTH(): Returns the month from the date passed.
e.g. SELECT MONTH(‘2020-05-25’);
MONTHNAME(): Returns the name of the month.
e.g. SELECT MONTHNAME (‘2020-05-25’);
12. DAYNAME(): Returns the name of the weekday.
e.g. SELECT DAYNAME (‘2020-05-25’);
DAYOFMONTH(): Returns the day of the month (1-31).
e.g. SELECT DAYOFMONTH (‘2020-05-25’);
13. DAY(): Returns the day.
e.g. SELECT DAY(‘2020-05-25’);
YEAR(): Returns the year.
e.g. SELECT YEAR(‘2020-05-25’);
14. DAYOFWEEK(): Returns the weekday index of the argument.
e.g. SELECT DAYOFWEEK(‘2020-04-10’);
DAYOFYEAR(): Returns the day of the year(1-366).
e.g. SELECT DAYOFYEAR(‘2020-04-10’);