Most Used SQL Functions in LeetCode Top 50
Mathematical Functions
ROUND(column, decimals): Rounds to specified decimal places
FLOOR(column): Rounds down to nearest integer
CEIL(column) / CEILING(column): Rounds up to nearest integer
ABS(column): Absolute value
MOD(a, b): Modulus (remainder of a/b)
String Functions
LENGTH(string): Number of characters
LEFT(string, n) / RIGHT(string, n): Get leftmost/rightmost characters
SUBSTRING(string, start, length): Extract substring
CONCAT(str1, str2): Join strings
LOWER(string) / UPPER(string): Case conversion
TRIM(string): Remove leading/trailing spaces
REPLACE(string, from, to): Replace substring
INSTR(string, substring): Position of substring (MySQL)
Date Functions
DATEDIFF(date1, date2): Days between dates
DATE_FORMAT(date, format): Format date (MySQL specific)
YEAR(date) / MONTH(date) / DAY(date): Extract year, month, or day
NOW() / CURDATE(): Current date/time
STR_TO_DATE(str, format): Convert string to date
Aggregate Functions
COUNT(*) / COUNT(DISTINCT col): Count rows or unique values
SUM(column): Total sum
AVG(column): Average value
MIN(column) / MAX(column): Minimum or maximum value
Most Used SQL Functions in LeetCode Top 50
Logical / Conditional Functions
IF(condition, true_value, false_value): Conditional logic (MySQL)
CASE WHEN THEN ELSE END: SQL standard conditional branching
ISNULL(value) / IFNULL(col, default): Handle nulls
Window Functions (Advanced)
ROW_NUMBER() OVER (...): Assign row number in partitions
RANK() / DENSE_RANK(): Rank rows
LEAD() / LAG(): Previous or next rows value
Other Useful Clauses
LIMIT n: Limit number of output rows (used for top-N queries)