Essential SQL Functions 👇👇
### DATE AND TIME FUNCTIONS:
-
NOW(): Returns the current date and time.
-
CURDATE(): Returns the current date.
-
CURTIME(): Returns the current time.
-
DATE(): Extracts the date part of a date or datetime expression.
-
DATEDIFF(): Returns the number of days between two date values.
-
YEAR(): Extracts the year.
-
MONTH(): Extracts the month.
-
DAY(): Extracts the day of the month.
-
HOUR(): Extracts the hour.
-
MINUTE(): Extracts the minute.
-
SECOND(): Extracts the second.
### AGGREGATE FUNCTIONS:
-
SUM(): Returns the sum of a set of values.
-
AVG(): Returns the average value of a numeric column.
-
MIN(): Returns the minimum value in a set of values.
-
MAX(): Returns the maximum value in a set of values.
-
COUNT(): Returns the number of rows that matches a specified condition.
-
COUNT(*): Returns the number of rows in a table.
-
COUNT(DISTINCT column_name): Returns the number of distinct values in a column.
### STRING FUNCTIONS:
-
CONCAT(): Concatenates two or more strings.
-
LENGTH(): Returns the length of a string.
-
UPPER(): Converts a string to upper-case.
-
LOWER(): Converts a string to lower-case.
-
LEFT(): Extracts a number of characters from a string (starting from left).
-
RIGHT(): Extracts a number of characters from a string (starting from right).
-
SUBSTRING(): Extracts a substring from a string.
### NUMERIC FUNCTIONS:
-
ROUND(): Rounds a number to a specified number of decimal places.
-
FLOOR(): Returns the largest integer value less than or equal to a number.
-
CEIL(): Returns the smallest integer value greater than or equal to a number.
-
ABS(): Returns the absolute value of a number.
### INFORMATION FUNCTIONS:
-
ISNULL(): Returns a specified value if the expression is NULL.
-
COALESCE(): Returns the first non-null value in a list.
-
NULLIF(): Returns NULL if the two expressions are equal.
### LOGICAL FUNCTIONS:
-
IF(): Returns one value if a condition is TRUE, and another value if it is FALSE.
-
CASE: Evaluates a list of conditions and returns one of multiple possible result expressions.
-
AND: Combines two or more conditions and returns TRUE if all conditions are TRUE.
-
OR: Combines two or more conditions and returns TRUE if any condition is TRUE.
-
NOT: Reverses the value of a boolean expression.
### JSON FUNCTIONS:
-
JSON_EXTRACT(): Extracts data from a JSON document.
-
JSON_OBJECT(): Creates a JSON object from a list of key-value pairs.
### WINDOW FUNCTIONS:
-
ROW_NUMBER(): Assigns a unique sequential integer to rows within a partition.
-
RANK(): Assigns a rank to each row within a partition.
-
DENSE_RANK(): Similar to RANK(), but without gaps in the ranking sequence.
-
NTILE(): Divides rows into a specified number of approximately equal groups.
### OTHER FUNCTIONS:
-
CAST(): Converts a value of one data type to another.
-
CONVERT(): Converts a value of one data type to another.
-
COALESCE(): Returns the first non-null expression among its arguments.
Here you can find SQL Interview Resources👇
https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02Like this post if you need more 👍❤️
Share with credits:
https://t.me/sqlspecialistHope it helps :)