0% found this document useful (0 votes)
0 views2 pages

LeetCode SQL Functions CheatSheet

The document outlines the most commonly used SQL functions categorized into mathematical, string, date, aggregate, logical, and window functions. It provides specific examples of each function, such as ROUND, LENGTH, DATEDIFF, COUNT, and IF, along with their purposes. Additionally, it mentions useful clauses like LIMIT for controlling output rows.

Uploaded by

maxsinghparihar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

LeetCode SQL Functions CheatSheet

The document outlines the most commonly used SQL functions categorized into mathematical, string, date, aggregate, logical, and window functions. It provides specific examples of each function, such as ROUND, LENGTH, DATEDIFF, COUNT, and IF, along with their purposes. Additionally, it mentions useful clauses like LIMIT for controlling output rows.

Uploaded by

maxsinghparihar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy