Professional Documents
Culture Documents
com
Searched Case:
CASE Aggregate Functions REPLACE(whole_string, string_to_replace,
WHEN name='John' THEN 'Name John' replacement_string): Replaces one string inside the
WHEN name='Steve' THEN 'Name Steve' SUM: Finds a total of the numbers provided whole string with another string.
ELSE 'Unknown'
COUNT: Finds the number of records SUBSTRING(string, [start_pos], [length]): Returns
END
part of a value, based on a position and length.
AVG: Finds the average of the numbers provided
With Clause/Common Table Expression
WITH queryname AS ( MIN: Finds the lowest of the numbers provided
SELECT col1, col2
MAX: Finds the highest of the numbers provided
FROM firsttable)
SELECT col1, col2..
Common Functions
FROM queryname…;
LENGTH(string): Returns the length of the provided
Subqueries string
Single Row:
SELECT id, last_name, salary POSITION(string IN substring): Returns the position
FROM employee of the substring within the specified string.
WHERE salary = (
CAST(expression AS datatype): Converts an
SELECT MAX(salary)
expression into the specified data type.
FROM employee
); NOW: Returns the current date, including time.
Multi Row CEIL(input_val): Returns the smallest integer greater
SELECT id, last_name, salary than the provided number.
FROM employee
WHERE salary IN ( FLOOR(input_val): Returns the largest integer less
SELECT salary than the provided number.
FROM employee
WHERE last_name LIKE 'C%' ROUND(input_val, [round_to]): Rounds a number to a
); specified number of decimal places.