SQL Cheat Sheet

SQL Cheat Sheet provides quick, concise reference material for SQL queries, aiding users in efficiently recalling commands and syntax, facilitating faster query writing and troubleshooting during interviews or practical scenarios.
ALTER

Short Description: 
The ALTER clause in SQL is used to modify or change the structure of an existing database object like a table, adding, removing, or modifying columns, constraints, or settings. 

What SQLInterview 
Says: The ALTER clause in SQL is a powerful command that allows modifications to the structure of database objects. It can be used to add, modify, or drop columns, constraints, indexes, and other properties of tables or databases. This command provides flexibility in altering existing schemas without the need to recreate the entire object, enabling database administrators to make changes to database structures efficiently.

AND

Short Description: 
The AND clause in SQL is a logical operator used to combine multiple conditions in a query. It requires that all specified conditions must be true for the row to be included in the result set. 

What SQLInterview Says: 
The AND clause in SQL is a logical operator that allows the conjunction of multiple conditions within a WHERE clause. When using AND, all specified conditions must evaluate to true for a row to be included in the query result. It's commonly used to narrow down results by combining different criteria. This operator operates by checking each condition and returning rows that meet all the specified conditions simultaneously.

ARRAY

Short Description: 
The ARRAY in SQL is a data type that allows the storage and manipulation of arrays, which are ordered collections of elements of the same data type within a single column in a database table. 

What SQLInterview Says: 
The ARRAY in SQL is a data type that enables the storage of arrays—ordered collections of elements—within a single column of a table. It allows for the storage of multiple values of the same data type in a structured format. PostgreSQL, for example, supports arrays of various data types, enabling efficient storage and retrieval of arrays within a database column. This functionality provides flexibility in managing and querying data, especially when dealing with multiple related values that belong together.

AS

Short Description
AS command in PostgreSQL is used to assign aliases to columns or tables in SQL queries. 

What SQLInterview Says
AS command in PostgreSQL is a versatile tool that allows you to assign aliases to columns or tables in SQL queries. Aliases provide alternative names for columns or tables, making the query results more readable and understandable. They can be used to give more meaningful names, simplify query syntax, or handle naming conflicts when joining multiple tables.

ASCII

Short Description:
ASCII in SQL returns the ASCII value of the first character in a string.

What SQLInterview Says:
The ASCII function in SQL is used to obtain the ASCII (American Standard Code for Information Interchange) value of the first character in a string expression. It takes a single character as input and returns an integer representing the ASCII value of that character. If the input string is empty, the function returns 0.

AVG

Short Description:
AVG in SQL is an aggregate function used to calculate the average value of a set of values within a column.

What SQLInterview Says:
AVG function in SQL is an aggregate function that computes the average value of a set of numerical values within a column. It calculates the sum of all values in the specified column and divides it by the total number of values to derive the average. This function is commonly used to obtain the average value of a dataset, providing valuable insights into the central tendency of numerical data.

BEGIN

Short Description: 
BEGIN statement in SQL is used to start a transaction explicitly, indicating the beginning of a series of SQL commands that should be treated as a single unit of work. 

What SQLInterview Says: 
BEGIN statement in SQL initiates an explicit transaction, marking the start of a sequence of SQL statements that need to be treated as a single unit of work. It is often used in conjunction with other transaction control statements (COMMIT, ROLLBACK) to manage atomicity, consistency, isolation, and durability (ACID properties) of the database transactions. The commands executed between BEGIN and COMMIT or ROLLBACK are treated as a single logical transaction, ensuring that either all changes are applied (committed) or none are (rolled back).

BETWEEN

Short Description:
BETWEEN in SQL is a comparison operator used to check if a value lies within a specified range.

What SQLInterview Says:
BETWEEN operator in SQL is used in a WHERE clause to determine whether a value lies within a specified range of values. It's inclusive, checking if a value is greater than or equal to a starting point and less than or equal to an ending point. This operator is helpful for filtering data based on a range of values in a column.

BTRIM

Short Description:
BTRIM in SQL removes specified characters from the beginning and end of a string.

What SQLInterview Says:
The BTRIM function in SQL is used to remove specified characters or spaces from the beginning and end of a string. It trims all leading and trailing occurrences of the characters specified in the trim expression from the input string. If no trim characters are provided, it removes spaces by default.

CASE

Short Description:
CASE in SQL is a conditional expression that allows for multiple conditions and return values based on those conditions.

What SQLInterview Says:
CASE expression in SQL provides conditional logic similar to IF-THEN-ELSE statements. It evaluates a set of conditions and returns a result based on the first condition that evaluates to true. It is versatile and allows the formulation of complex conditional logic within SQL queries.

CHECK

Short Description: 
CHECK constraint in SQL is used to enforce specific conditions or rules on the values that can be inserted or updated in a column, ensuring that only values meeting the specified criteria are allowed. 

What SQLInterview Says:
CHECK constraint in SQL is a table constraint that allows defining conditions or rules for column values. When applied to a column, it restricts the values that can be inserted or updated to those that satisfy the specified condition. This constraint ensures data integrity by validating the data before it is added or modified in the database, preventing invalid or unwanted values from being stored.

CHR

Short Description:
CHR function is used to return a character based on the ASCII code provided as an argument.

What SQLInterview Says:
CHR function in SQL takes an ASCII code as an argument and returns the character represented by that ASCII code. It's particularly useful when converting numerical ASCII codes into their corresponding characters. For example, CHR(65) returns the character 'A' as 65 represents the ASCII code for 'A'.

COALESCE

Short Description:
COALESCE in SQL is a function used to return the first non-null value from a list of expressions.

What SQLInterview Says:
COALESCE function in SQL is utilized to evaluate a list of expressions and return the first non-null value encountered in the list. It takes multiple arguments and returns the first argument that is not NULL. If all arguments are NULL, it returns NULL. This function is commonly used to handle NULL values within queries, allowing substitution of NULL with alternate values.

CONCAT

Short Description:
CONCAT in SQL is used to concatenate two or more strings together into a single string.

What SQLInterview Says:
The CONCAT function in SQL is employed to join multiple strings into a single string. It takes two or more string expressions as arguments and concatenates them in the order they are specified. If any argument is NULL, it treats it as an empty string for concatenation.

COUNT

Short Description:
COUNT in SQL is an aggregate function used to count the number of rows or non-null values within a column.

What SQLInterview Says:
The COUNT function in SQL is an aggregate function that tallies the number of rows in a specified column or the number of non-null values within that column. It returns the count of rows that meet the specified criteria, providing insights into the number of records or instances that match the conditions given in the query.

CREATE TABLE

Short Description: 
CREATE TABLE statement in SQL is used to define and create a new table in a database, specifying the table name, columns, data types, constraints, and other properties.

What SQLInterview Says: 
CREATE TABLE statement is a Data Definition Language (DDL) command in SQL used to create a new table in a database. It defines the structure of the table by specifying column names, their data types, constraints (such as primary keys, foreign keys, etc.), default values, and other table properties. This statement allows users to organize and store data in a structured format within a database.

DATE_PART

Short Description:
DATE_PART() function is used to extract a specific part (such as year, month, day, hour, etc.) from a date or timestamp.

What SQLInterview Says:
DATE_PART() function in SQL is used to retrieve a specific component, such as year, month, day, hour, minute, second, etc., from a date or timestamp. It takes two arguments: the date part to extract and the date or timestamp from which to extract the specified part. This function is valuable for dissecting date or timestamp values and obtaining specific components, allowing for detailed analysis or manipulation of temporal data.

DELETE

Short Description:
DELETE statement in SQL is used to remove rows from a table based on specified criteria, effectively deleting data from the table. 
 

What SQLInterview Says:
DELETE statement in SQL is used to remove rows from a table that match specific conditions provided in the WHERE clause. It is a Data Manipulation Language (DML) statement that permanently deletes data from a table. It removes specific rows while retaining the table structure and other data. Care should be taken when using DELETE as it permanently erases data, and there's usually no direct undo capability after a commit.

DENSE_RANK

Short Description: 
DENSE_RANK function in SQL is used to assign a rank to each row in a result set, ensuring consecutive ranking without gaps. If multiple rows share the same rank, the next rank value increments by one without leaving gaps in the ranking sequence. 

What SQLInterview Says: 
DENSE_RANK function in SQL is a window function used to assign ranks to rows within a result set based on specified ordering criteria. It computes rankings in a way that ensures consecutive ranks without leaving gaps, even if multiple rows have the same values that determine their ranking. Unlike RANK, DENSE_RANK doesn’t leave gaps in the ranking sequence and provides consecutive rankings to rows sharing the same rank value.

DISTINCT

Short Description: 
The DISTINCT command in PostgreSQL is used to retrieve unique values from one or more columns in a table. 

What SQLInterview Says: 
The DISTINCT command in PostgreSQL is a useful tool when you want to eliminate duplicate values and retrieve only unique data points from one or more columns in a table. It filters out redundant entries, allowing you to focus on distinct values. This command is commonly used in scenarios where you need to obtain unique combinations of values or count the occurrences of distinct values.

DROP

Short Description:
DROP statement is used to delete or remove database objects, such as tables, views, indexes, or databases themselves.

What SQLInterview Says:
DROP statement in SQL is used to delete existing database objects like tables, views, indexes, or databases themselves. It permanently removes the specified object from the database schema. This operation cannot be rolled back, so it's crucial to use it with caution as dropping an object removes all associated data and schema definitions.

EXCEPT

Short Description:
EXCEPT operator is used to retrieve distinct rows from the left query result that do not appear in the right query result.

What SQLInterview Says:
EXCEPT operator in SQL is used to compare two queries and retrieve the distinct rows from the first (left) query that are not present in the second (right) query. It returns only distinct rows by comparing the result sets of both queries and eliminating rows found in the second query result from the first query result. This operator is beneficial for finding the difference between two result sets, allowing you to identify unique rows present in one set but not in another.

EXTRACT

Short Description:
EXTRACT in SQL is used to extract and retrieve specific parts (such as year, month, day, etc.) from date and time values.

What SQLInterview Says:
EXTRACT function in SQL is employed to retrieve specific components, like year, month, day, hour, minute, etc., from a date or timestamp field in the database. It allows users to extract and work with individual components of date and time values stored in the database. This function is useful for performing analysis or filtering based on specific date or time components.

FROM

Short Description: 
FROM command in PostgreSQL is used to specify the table or tables from which data is retrieved in an SQL query. 

What SQLInterview Says: 
FROM command is a fundamental part of an SQL query in PostgreSQL. It allows you to specify the table or tables that will be used as the data source for the query. The FROM clause is typically used immediately after the SELECT statement and precedes any JOIN or WHERE clauses. It enables you to define the source tables for retrieving data and perform operations such as filtering, joining, and aggregating.

FULL OUTER JOIN

Short Description:
FULL OUTER JOIN function combines the results of both LEFT JOIN and RIGHT JOIN. It returns all records when there is a match in either the left or right table. If there is no match, NULL values are included for columns from the table without a matching row.

What SQLInterview Says:
FULL OUTER JOIN in SQL combines the results of both the LEFT JOIN and RIGHT JOIN. It retrieves all records from both tables specified in the query. If there are matching rows between the tables, those records are included in the result set. If there's no match for a row from one table in the other table, NULL values are added for the columns from the table without a match. This type of join is useful for merging data from two tables, keeping all records from both tables, and identifying unmatched rows.

GENERATED COLUMN

Short Description: 
GENERATED COLUMN in SQL allows the creation of columns in a table that derive their values based on expressions or functions. These columns are computed dynamically when rows are inserted or updated, rather than storing physical data. 

What SQLInterview Says: 
GENERATED COLUMN in SQL enables the creation of columns whose values are determined by an expression or function based on other columns within the same table. These columns don't store data physically; instead, they are computed dynamically when rows are inserted or updated. They offer the ability to generate values based on specified rules, providing efficient ways to derive information without storing redundant data.

GRANT

Short Description:
GRANT SQL clause used to grant specific privileges or permissions on database objects to users or roles.

What SQLInterview Says:
 GRANT clause in SQL is utilized to provide specific privileges or permissions on database objects, such as tables, views, sequences, or schemas, to users or roles within the database. This command is crucial for managing security and access control within PostgreSQL. It allows the database administrator to delegate certain rights to other users or roles, enabling them to perform actions like SELECT, INSERT, UPDATE, DELETE, etc., on the specified database objects.

GROUP BY

Short Description:
GROUP BY in SQL is a clause used to group rows that share a common value in one or more columns, allowing aggregate functions to be performed on each group separately.

What SQLInterview Says:
GROUP BY clause in SQL is used to group rows together based on a specified column or columns. It collects rows that have identical values in the specified column(s) and forms them into groups. After grouping, aggregate functions like SUM, COUNT, AVG, etc., can be applied to each group independently. It's valuable for performing aggregate operations on subsets of data within a table.

HAVING

Short Description: 
HAVING in SQL is a clause used to filter grouped results based on specified conditions involving aggregated values, allowing for targeted selection of grouped data. 

What SQLInterview Says: 
HAVING clause in SQL is utilized to filter aggregated data based on specified conditions after grouping rows using the GROUP BY clause. Unlike the WHERE clause that filters individual rows before grouping, HAVING operates on aggregated values, allowing for the selection of grouped results that meet certain criteria. This clause is particularly valuable when needing to apply conditions to the results of aggregate functions (e.g., SUM, COUNT, AVG) to determine which grouped data should be included in the final output. It aids in narrowing down grouped data sets by imposing conditions on the results of these aggregates, facilitating more precise and tailored analysis of data in SQL queries.

IN

Short Description: 
IN function in SQL is an operator used to check if a value matches any value in a list of specified values. 

What SQLInterview Says: 
IN function is useful for filtering data based on multiple values within a specified list, providing a concise and efficient alternative to using multiple OR conditions.

INITCAP

Short Description: 
INITCAP function in SQL is used to capitalize the first letter of each word in a string while converting the remaining characters to lowercase. 

What SQLInterview Says: 
INITCAP function in SQL is designed to capitalize the first letter of every word within a string, ensuring that subsequent characters are converted to lowercase. It's commonly employed for formatting purposes, especially when consistent capitalization is needed for titles, names, or sentences.

INNER JOIN

Short Description:
INNER JOIN function is used to combine rows from two or more tables based on a related column between them. It returns only the rows where a match is found in both tables, excluding rows that don't have a matching row in the other table.

What SQLInterview Says:
INNER JOIN in SQL retrieves rows from both tables specified in the query, where there is a match based on the specified condition or columns. It combines rows from tables that have matching values in the related columns and excludes rows that don't have a match in the other table. This join type is useful for selecting data that exists in both tables and filtering out unmatched rows.

INSERT INTO

Short Description: 
INSERT INTO clause in SQL is used to add new records or rows into a table, specifying the columns and their corresponding values. 

What SQLInterview Says: 
INSERT INTO statement in SQL is used to insert new rows into a table. It allows the addition of specific data values into columns or all columns of a table. This statement is vital for populating a database table with fresh records. It can be used with explicit column names to insert data into specific columns or without specifying column names to insert data in the order the columns were defined in the table.

INTERSECT

Short Description:
INTERSECT operator is used to retrieve distinct rows that appear in both the left and right query results.

What SQLInterview Says:
INTERSECT operator in SQL compares two queries and returns distinct rows that are common to both query results. It retrieves rows that appear in both the result set of the first (left) query and the result set of the second (right) query. This operator is valuable for finding the intersection of rows between two sets, allowing you to identify common elements present in both sets.

IS NULL

Short Description:
IS NULL in SQL is a condition used to filter rows where a specified column contains null values.

What SQLInterview Says:
IS NULL condition in SQL is used to filter rows in a query result where the specified column's value is NULL. It returns rows where the column contains no value (i.e., NULL). This condition is valuable when querying for records with missing or unknown data within a specific column.

LAG

Short Description:
LAG in SQL is a window function used to access data from preceding rows within the result set based on a specified offset.

What SQLInterview Says:
LAG function in SQL is a window function that allows access to column values from preceding rows within the result set. It retrieves the value of a specified column from the preceding row(s) based on a specified offset within the partition of a query result. This function is beneficial for comparing values from the current row with those in preceding rows or for accessing previous data points in a sequence.

LEAD

Short Description:
LEAD in SQL is a window function used to access data from subsequent rows within the result set based on a specified offset.

What SQLInterview Says:
LEAD function in SQL is part of the window function family and is utilized to fetch data from subsequent rows within the result set. It allows retrieval of column values from the next row(s) based on a specified offset within the partition of a query result. This function is helpful for comparing values from the current row with those in subsequent rows or for accessing future data points in a sequence.

LEFT

Short Description:
LEFT() string function is used to extract a specified number of characters from the left side of a string.

What SQLInterview Says:
LEFT() function in SQL is used to retrieve a specified number of characters from the beginning (left side) of a string. It takes two arguments: the input string and the number of characters to extract. The function returns a substring containing the specified number of characters from the left side of the input string. This function is useful for extracting portions of strings, especially when dealing with textual data where specific lengths or portions are required.

LEFT JOIN

Short Description:
LEFT JOIN function is used to retrieve all records from the left table and matching records from the right table based on a specified condition. It includes all rows from the left table and only matching rows from the right table. If no match is found, NULL values are included for columns from the right table.

What SQLInterview Says:
 LEFT JOIN in SQL retrieves all records from the left table specified in the query and matching records from the right table. If there are no matches found in the right table, NULL values are included for the columns from the right table in the result set. This type of join is useful when you want all records from the left table and related data from the right table, regardless of whether there is a match.

LENGTH

Short Description:
LENGTH in SQL is used to determine the number of characters in a string.

What SQLInterview Says:
LENGTH function in SQL is utilized to calculate the length of a string in terms of the number of characters it contains. It returns an integer representing the number of characters in the specified string expression. This function is commonly used to assess the length of strings, which can be beneficial in various data manipulation and validation tasks.

LIKE

Short Description:
LIKE in SQL is a comparison operator used to match patterns in strings using wildcard characters.

What SQLInterview Says:
The LIKE operator in SQL is used in a WHERE clause to search for a specified pattern within a string column. It allows the use of wildcard characters such as % (matches zero or more characters) and _ (matches a single character) to perform pattern-matching operations. This operator is valuable for searching and filtering data based on specific patterns in string values.

LIMIT

Short Description: 
The LIMIT command in PostgreSQL is used to restrict the number of rows returned by an SQL query. 

What SQLInterview Says: 
The LIMIT command is a powerful tool in PostgreSQL that allows you to control the number of rows returned by a query. It is typically used at the end of the SELECT statement and is followed by an integer value specifying the maximum number of rows to retrieve. This command is useful when you want to fetch only a subset of records, especially in situations where you have a large result set and want to limit the output.

MAX

Short Description:
MAX in SQL is an aggregate function used to retrieve the maximum value within a column or set of values.

What SQLInterview Says:
MAX function in SQL is an aggregate function that retrieves the maximum value from a specified column or set of values. It scans through the dataset and returns the highest value found within the column. It's often used to find the maximum value within a dataset, providing insights into the largest value present in the specified column.

MIN

Short Description:
MIN in SQL is an aggregate function used to retrieve the minimum value within a column or set of values.

What SQLInterview Says:
The MIN function in SQL is an aggregate function that retrieves the minimum value from a specified column or set of values. It scans through the dataset and returns the lowest value found within the column. It's commonly used to find the minimum value within a dataset, providing insights into the smallest value present in the specified column.

NOT

Short Description:
NOT in SQL is a logical operator used to negate a condition or reverse the result of a Boolean expression.

What SQLInterview Says:

NOT operator in SQL is a logical operator used to negate the result of a condition. It reverses the Boolean value of an expression, returning FALSE if the condition is true and TRUE if the condition is false. This operator is valuable for performing operations that require the opposite of a given condition.

NOT NULL

Short Description: 
NOT NULL constraint in SQL is used to specify that a column cannot contain any NULL values, ensuring that every row must have a non-null value in that column. 

What SQLInterview Says: 
NOT NULL constraint in SQL is a table constraint that ensures a column does not allow NULL values. When applied to a column during table creation or modification, it mandates that every row must contain a valid (non-NULL) value for that particular column. It guarantees data integrity by preventing the insertion of NULL values and is beneficial when certain columns are required to always contain data.

NULLIF

Short Description:
NULLIF() function is used to compare two expressions. It returns NULL if the two expressions are equal; otherwise, it returns the first expression.

What SQLInterview Says:
NULLIF() function in SQL compares two expressions. If the two expressions are equal, it returns NULL. However, if the expressions are not equal, it returns the first expression. This function is useful when you want to replace specific values with NULL, typically to handle scenarios where specific values should be treated as missing or invalid.

OR

Short Description: 
OR command in PostgreSQL is a logical operator used to combine multiple conditions in a WHERE clause to retrieve rows that meet at least one of the specified conditions. 

What SQLInterview Says: 
OR command allows you to perform logical operations on multiple conditions in a SQL query. It is commonly used in conjunction with the WHERE clause to create more complex filtering conditions. When used, the OR operator evaluates each condition separately and returns rows that satisfy at least one of the conditions. This provides flexibility in querying the database and expands the range of search possibilities.

ORDER BY

Short Description:
ORDER BY clause is used to sort the result set of a query based on specified columns or expressions in ascending or descending order.

What SQLInterview Says:
ORDER BY clause in SQL is used to sort the rows retrieved by a SELECT statement. It arranges the result set in either ascending (default) or descending order based on the specified columns or expressions. This clause is helpful for organizing query results according to certain criteria, such as alphabetical order, numerical order, or date order, making it easier to analyze and understand the data.

OVER

Short Description: 
OVER in SQL is used in conjunction with window functions to define the window or set of rows over which a function operates. 

What SQLInterview Says: 
OVER clause in SQL is used with window functions to specify the window or set of rows within the result set that the function will operate on. It defines the partitioning and ordering of rows for window functions, enabling them to perform calculations or retrieve values within specific partitions or orderings of the result set. This clause is crucial for controlling the scope and behavior of window functions.

PARTITION BY

Short Description: 
PARTITION BY clause in SQL is used in conjunction with analytical functions to divide the result set into partitions based on specified column(s), enabling separate calculations or analysis within each partition. 

What SQLInterview Says: 
PARTITION BY clause in SQL is used with analytical functions to create partitions within the result set. It divides the data into separate groups based on specified column(s) or expressions. When combined with analytical functions like ROW_NUMBER(), RANK(), or SUM(), it allows performing calculations or analysis separately within each partition. This clause is beneficial for comparing or evaluating data within specific groups or subsets.

POSITION

Short Description:
POSITION in SQL is used to find the position of a substring within a string.

What SQLInterview Says:
POSITION function in SQL is used to determine the position of a specified substring within a string expression. It returns the position of the first occurrence of the substring within the string. If the substring is not found, it returns 0. The function takes two arguments: the substring to search for and the string in which to search for that substring.

RANDOM

Short Description: 
RANDOM clause in SQL is used to retrieve random rows from a table. It is often employed in conjunction with ORDER BY to shuffle the result set and fetch a random selection of rows. 

What SQLInterview Says: 
RANDOM clause in SQL, particularly in PostgreSQL, is a function used to generate random values. When used in combination with ORDER BY, it allows the retrieval of random rows from a table. This can be beneficial in scenarios where you need to sample or select a random subset of data for analysis or presentation. The RANDOM function generates a random value for each row and then sorts the result set based on these values, allowing you to obtain a randomized selection.

RANK

Short Description: 
RANK() function in SQL assigns a unique rank to each row within a result set based on the specified ordering, allowing for ties and leaving gaps in ranks. 

What SQLInterview Says: 
RANK() function in SQL is used to assign a unique rank to each row within a result set, based on a specified ordering. It handles ties by assigning the same rank to rows with identical values and creates gaps in ranks for subsequent rows. This function is useful for ranking data, but it may not produce consecutive ranks in the case of ties.

REPLACE

Short Description: 
REPLACE function in SQL is used to replace occurrences of a specified substring within a string with another substring. 

What SQLInterview Says: 
REPLACE function in SQL is employed to replace occurrences of a specific substring within a string with a different substring. It searches for a target string and replaces it with the provided replacement string in the given input string. This function is helpful for modifying or formatting string data within queries.

REVERSE

Short Description: 
REVERSE function in SQL is used to reverse the order of characters within a string value. 

What SQLInterview Says: 
REVERSE function in SQL is used to reverse the order of characters within a string. It takes a string input and returns the characters in reverse order. This function is often used to reverse the sequence of characters within a string for various purposes, such as data transformation or formatting.

REVOKE

Short Description:
REVOKE: SQL clause used to revoke specific privileges or permissions on database objects from users or roles.

What SQLInterview Says:
REVOKE clause in SQL is used to retract or revoke previously granted permissions or privileges from users or roles on database objects such as tables, views, schemas, or functions. This command plays a crucial role in managing security within a database environment by removing specific access rights previously granted using the GRANT command. It allows database administrators to restrict or modify user or role access to certain operations on database objects.

RIGHT

Short Description:
RIGHT() string function is used to extract a specified number of characters from the right side of a string.

What SQLInterview Says:
RIGHT() function in SQL extracts a specified number of characters from the end (right side) of a string. It takes two arguments: the input string and the number of characters to extract. This function returns a substring containing the specified number of characters from the right side of the input string. It's beneficial for extracting portions of strings, particularly when dealing with textual data requiring specific lengths or portions from the end of the string.

RIGHT JOIN

Short Description:
RIGHT JOIN function is used to retrieve all records from the right table and matching records from the left table based on a specified condition. It includes all rows from the right table and only matching rows from the left table.

What SQLInterview Says:
RIGHT JOIN in SQL retrieves all records from the right table specified in the query and matching records from the left table. If there are no matches found in the left table, NULL values are included for the columns from the left table in the result set. This type of join is beneficial when you want all records from the right table and related data from the left table, and it allows you to perform operations considering the right table as the primary focus.

ROLLBACK

Short Description: 
ROLLBACK clause in SQL is used to undo or revert the changes made in a transaction that has not been committed yet, returning the database to its state before the transaction began. 

What SQLInterview Says: 
ROLLBACK statement in SQL is a crucial command used to undo and discard changes made within a transaction. It is typically used to revert any modifications if an error occurs during a series of database operations performed within a transaction. When executed, ROLLBACK reverts all changes back to the last COMMIT or SAVEPOINT, ensuring data integrity by discarding any uncommitted changes.

ROW_NUMBER

Short Description: 
ROW_NUMBER() function in SQL assigns a unique sequential integer to each row within a partition of a result set based on the specified ordering. 

What SQLInterview Says: 
ROW_NUMBER() function in SQL is used to assign a unique sequential integer to each row within a specified partition of a result set. It is particularly useful for ranking or identifying specific rows based on a defined order within a partition. This function doesn't affect the actual table; it's used in queries to generate a row number for each row.

SAVEPOINT

Short Description: 
SAVEPOINT statement in SQL creates a named point within a transaction to which you can later roll back, providing a way to partially undo changes made within a transaction. 

What SQLInterview Says: 
SAVEPOINT statement in SQL allows you to set a named marker within a transaction, creating a point to which you can roll back later if needed. It provides a level of granularity for rolling back changes within a transaction, allowing partial rollback rather than the entire transaction. This feature is helpful in complex transactions where you might need to undo specific changes without reverting all modifications.

SELECT

Short Description: 
The SELECT command in PostgreSQL is used to retrieve data from one or more tables in a database. 

What SQLInterview Says: 
The SELECT command in PostgreSQL is a fundamental SQL statement that allows you to retrieve data from one or more tables in a database. It forms the core of most SQL queries and provides the ability to specify which columns to include in the result set, apply filters using WHERE clause conditions, perform aggregations with functions like COUNT, SUM, and AVG, and join multiple tables together.

SUBSTRING

Short Description:
SUBSTRING() function is used to extract a substring from a string based on a specified starting position and length.

What SQLInterview Says:
SUBSTRING() function in SQL is used to extract a portion of a string, known as a substring, based on specified starting position and length parameters. It takes three arguments: the input string, the starting position (from where to start extracting), and an optional length parameter (the number of characters to extract). This function is valuable for extracting specific parts of a string, enabling operations on partial or desired portions of textual data.

SUM

Short Description:
SUM in SQL is an aggregate function used to calculate the total sum of values within a column or set of values.

What SQLInterview Says:
SUM function in SQL is an aggregate function that computes the sum of all values in a specified column or set of values. It adds up all the numeric values present in the specified column and returns the total sum. This function is commonly used to obtain the aggregated sum of numerical data, providing insights into the combined value of the dataset.

TRANSLATE

Short Description: 
TRANSLATE function in SQL is used to replace characters in a string based on a mapping of each character in the input string to a corresponding character in the provided translation string. 

What SQLInterview Says: 
TRANSLATE function in SQL is utilized to replace individual characters in a string based on a one-to-one mapping specified in the translation string. It searches for occurrences of characters in the input string and replaces them with corresponding characters from the translation string. This function allows for character-level substitution and is useful for specific character transformations within a string.

UNION

Short Description:
UNION in SQL is used to combine the results of two or more SELECT queries into a single result set, removing duplicate rows by default.

What SQLInterview Says:
UNION operator in SQL is employed to merge the result sets of multiple SELECT queries into a unified result set. It effectively combines rows from different queries into one result set while removing duplicate rows by default. However, if you wish to retain duplicate rows, you can use UNION ALL. This operator is useful for aggregating data from multiple sources or tables with similar structures.

UNION ALL

Short Description:
UNION ALL in SQL is used to combine the results of two or more SELECT queries into a single result set, including all rows (including duplicates) from each query.

What SQLInterview Says:
UNION ALL operator in SQL is similar to UNION but retains all rows, including duplicates, from the result sets of the individual SELECT queries. It combines rows from different queries into one result set without eliminating duplicate rows. This operator is beneficial when you want to combine and see all results from multiple sources without eliminating any duplicates.

UNIQUE

Short Description: 
UNIQUE constraint in SQL is used to ensure that the values in a column or a group of columns are unique across all the rows in a table, preventing duplicate entries. 

What SQLInterview Says: 
UNIQUE constraint in SQL is a database constraint that ensures the uniqueness of values within one or more columns of a table. When applied to a column or a combination of columns, it guarantees that no two rows in the table have the same value(s) for that column or combination of columns. It prevents duplicate entries and is useful for maintaining data integrity by enforcing uniqueness among specified columns.

UPPER

Short Description: 
UPPER function in SQL is used to convert characters in a string to uppercase, transforming all lowercase letters to their uppercase equivalents within the specified string. 

What SQLInterview Says: 
UPPER function in SQL is a string manipulation function used to convert all characters in a string expression to uppercase. It is commonly employed to standardize text data by converting lowercase letters to their corresponding uppercase forms. This function facilitates case-insensitive comparisons and ensures uniformity in text data.

VIEW

Short Description: 
VIEW statement in SQL is used to create a virtual table based on the result set of a SELECT query, allowing users to query the view as they would a regular table without storing the actual data.

What SQLInterview Says: 
VIEW statement in SQL is used to create a virtual table that does not store data itself but instead represents the result set of a query. It acts as a saved query that can be referenced and queried just like a regular table. Views can simplify complex queries, enhance security by restricting access to specific columns or rows, and provide a way to encapsulate frequently used queries into reusable objects.