MySQL Functions

MySQL Functions

  • Functions are used to perform some specific task.
  • Every functions has a particular pre-defined tasks.
  • functions are categorized into two parts.

1. Single Row Functions

  • These functions operates on a single row at a time.
  • These functions are categorized into following parts-

i. Math Functions
ii. String Functions
iii. Date and Time functions etc.

2. Multi Row / Aggregate Functions

  • These functions operates on multiple rows simultaneously.
  • Some of the Aggregate Functions are-
Function Purpose Syntax Example
COUNT() Counts number of rows (ignores NULL) SELECT COUNT(column_name) FROM table; SELECT COUNT(ID) FROM STUDENT;
SUM()  Returns total sum of numeric column SELECT SUM(column_name) FROM table; SELECT SUM(Marks) FROM RESULT;
AVG() Returns average of numeric column SELECT AVG(column_name) FROM table; SELECT AVG(Salary) FROM EMPLOYEE;
MIN() Returns smallest value in the column SELECT MIN(column_name) FROM table; SELECT MIN(Price) FROM PRODUCT;
MAX() Returns largest value in the column SELECT MAX(column_name) FROM table; SELECT MAX(Score) FROM EXAM;

SQL Important Notes

SQL Multiple Choice

Leave a Reply

Your email address will not be published. Required fields are marked *