Sat. Feb 22nd, 2025
  1. SELECT Statement:
    • Definition: Retrieves data from one or more tables.
    • Example: SELECT column1, column2 FROM table WHERE condition;
  2. INSERT INTO Statement:
    • Definition: Adds new records to a table.
    • Example: INSERT INTO table (column1, column2) VALUES (value1, value2);
  3. UPDATE Statement:
    • Definition: Modifies existing records in a table.
    • Example: UPDATE table SET column1 = value1 WHERE condition;
  4. DELETE Statement:
    • Definition: Removes records from a table.
    • Example: DELETE FROM table WHERE condition;
  5. CREATE TABLE Statement:
    • Definition: Creates a new table.
    • Example: CREATE TABLE table (column1 datatype, column2 datatype);
  6. ALTER TABLE Statement:
    • Definition: Modifies an existing table structure.
    • Example: ALTER TABLE table ADD column3 datatype;
  7. DROP TABLE Statement:
    • Definition: Deletes an existing table.
    • Example: DROP TABLE table;
  8. SELECT DISTINCT Statement:
    • Definition: Retrieves unique values from a column.
    • Example: SELECT DISTINCT column1 FROM table;
  9. COUNT() Function:
    • Definition: Counts the number of rows in a result set.
    • Example: SELECT COUNT(column1) FROM table WHERE condition;
  10. GROUP BY Clause:
    • Definition: Groups rows based on the values in specified columns.
    • Example: SELECT column1, COUNT(column2) FROM table GROUP BY column1;
  11. SELECT Statement:
    • Retrieves data from one or more tables.
  12. WHERE Clause:
    • Filters records based on a specified condition.
  13. ORDER BY Clause:
    • Sorts the result set in ascending or descending order.
  14. GROUP BY Clause:
    • Groups rows based on the values in specified columns.
  15. COUNT() Function:
    • Counts the number of rows in a result set.
  16. SUM() Function:
    • Calculates the sum of values in a numeric column.
  17. AVG() Function:
    • Calculates the average value of a numeric column.
  18. MIN() Function:
    • Retrieves the smallest value in a column.
  19. MAX() Function:
    • Retrieves the largest value in a column.
  20. INNER JOIN:
    • Combines rows from two or more tables based on a related column.
  21. LEFT JOIN:
    • Retrieves all rows from the left table and the matched rows from the right table.
  22. RIGHT JOIN:
    • Retrieves all rows from the right table and the matched rows from the left table.
  23. FULL OUTER JOIN:
    • Retrieves all rows when there is a match in either the left or right table.
  24. HAVING Clause:
    • Filters the result set based on aggregate values.
  25. DISTINCT Keyword:
    • Retrieves unique values from a column.
  26. LIKE Operator:
    • Searches for a specified pattern in a column.
  27. IN Operator:
    • Specifies multiple values for a WHERE clause.
  28. BETWEEN Operator:
    • Retrieves values within a specified range.
  29. CASE Statement:
    • Performs conditional logic within a query.
  30. UNION Operator:
    • Combines the result sets of two or more SELECT statements.
  31. DISTINCT Keyword:
    • Retrieves unique values from a column.
  32. LIKE Operator:
    • Searches for a specified pattern in a column.
  33. IN Operator:
    • Specifies multiple values for a WHERE clause.
  34. BETWEEN Operator:
    • Retrieves values within a specified range.
  35. CASE Statement:
    • Performs conditional logic within a query.
  36. UNION Operator:
    • Combines the result sets of two or more SELECT statements.
  37. INTERSECT Operator:
    • Retrieves common rows between two SELECT statements.
  38. EXCEPT Operator:
    • Retrieves rows from the first SELECT statement that are not present in the second.
  39. AS Keyword:
    • Renames a column or table in the result set.
  40. IS NULL Operator:
    • Checks for NULL values in a column.
  41. IS NOT NULL Operator:
    • Checks for non-NULL values in a column.
  42. INNER JOIN with USING:
    • Joins tables based on a common column using the USING keyword.
  43. LEFT JOIN with USING:
    • Retrieves all rows from the left table and matched rows from the right using the USING keyword.
  44. RIGHT JOIN with USING:
    • Retrieves all rows from the right table and matched rows from the left using the USING keyword.
  45. FULL OUTER JOIN with USING:
    • Retrieves all rows when there is a match in either the left or right table using the USING keyword.
  46. COUNT(DISTINCT Column):
    • Counts the number of unique values in a column.
  47. CONCAT() Function:
    • Concatenates two or more strings.
  48. UPPER() Function:
    • Converts a string to uppercase.
  49. LOWER() Function:
    • Converts a string to lowercase.
  50. LENGTH() Function:
    • Returns the length of a string.
  51. TRIM() Function:
    • Removes leading and trailing spaces from a string.
  52. ROUND() Function:
    • Rounds a numeric value to the nearest integer.
  53. RAND() Function:
    • Generates a random decimal value between 0 and 1.
  54. CURRENT_DATE Function:
    • Retrieves the current date.
  55. CURRENT_TIME Function:
    • Retrieves the current time.
  56. CURRENT_TIMESTAMP Function:
    • Retrieves the current timestamp.
  57. DATEDIFF() Function:
    • Calculates the difference between two dates.
  58. COALESCE() Function:
    • Returns the first non-NULL value in a list.
  59. NULLIF() Function:
    • Returns NULL if two expressions are equal; otherwise, returns the first expression.
  60. ROW_NUMBER() Function:
    • Assigns a unique number to each row within a partition of a result set.
  61. RANK() Function:
    • Assigns a rank to each row within a result set.
  62. DENSE_RANK() Function:
    • Assigns a dense rank to each row within a result set.
  63. LEAD() Function:
    • Accesses data from a subsequent row within the same result set.
  64. LAG() Function:
    • Accesses data from a preceding row within the same result set.
  65. PARTITION BY Clause:
    • Divides the result set into partitions to which the window function is applied.
  66. FIRST_VALUE() Function:
    • Returns the first value in an ordered set of values.
  67. LAST_VALUE() Function:
    • Returns the last value in an ordered set of values.
  68. NTH_VALUE() Function:
    • Returns the nth value in an ordered set of values.
  69. HAVING COUNT() > 1:
    • Filters groups based on having more than one occurrence.
  70. CASCADE Option in DELETE:
    • Deletes all rows in child tables when a record in the parent table is deleted.
  71. SET NULL Option in DELETE:
    • Sets foreign key columns to NULL in child tables when a record in the parent table is deleted.
  72. SET DEFAULT Option in DELETE:
    • Sets foreign key columns to their default values in child tables when a record in the parent table is deleted.
  73. CASCADE Option in UPDATE:
    • Updates foreign key values in child tables when a record in the parent table is updated.
  74. SET NULL Option in UPDATE:
    • Sets foreign key columns to NULL in child tables when a record in the parent table is updated.
  75. SET DEFAULT Option in UPDATE:
    • Sets foreign key columns to their default values in child tables when a record in the parent table is updated.
  76. FOR UPDATE Clause:
    • Locks rows selected for update, preventing other users from modifying them.
  77. FOR SHARE Clause:
    • Locks rows selected for read, preventing other users from updating or deleting them.
  78. UNION ALL Operator:
    • Combines the result sets of two or more SELECT statements, including duplicates.
  79. CHECK Constraint:
    • Ensures that values in a column meet specific conditions.
  80. PRIMARY KEY Constraint:
    • Enforces the uniqueness of values in a column or a set of columns.
  81. FOREIGN KEY Constraint:
    • Establishes a link between data in two tables, preventing actions that would destroy the link.
  82. DEFAULT Constraint:
    • Provides a default value for a column when no value is specified.
  83. INDEX:
    • Improves the speed of data retrieval operations on a database table.
  84. CREATE VIEW Statement:
    • Creates a virtual table based on the result set of a SELECT statement.
  85. CREATE INDEX Statement:
    • Creates an index on a table.
  86. ALTER INDEX Statement:
    • Modifies an existing index.
  87. DROP INDEX Statement:
    • Removes an index from a table.
  88. TRANSACTION:
    • A sequence of one or more SQL statements treated as a single unit of work.
  89. COMMIT Statement:
    • Saves changes made during the current transaction.
  90. ROLLBACK Statement:
    • Undoes changes made during the current transaction.
  91. SAVEPOINT Statement:
    • Sets a point within a transaction to which you can later roll back.
  92. ROLLBACK TO SAVEPOINT Statement:
    • Undoes all changes made since a specified savepoint was established.
  93. SET TRANSACTION ISOLATION LEVEL:
    • Sets the isolation level for the current transaction.
  94. UNIQUE Constraint:
    • Ensures that all values in a column or a set of columns are unique.
  95. JOIN Clause:
    • Combines rows from two or more tables based on a related column.
  96. EXISTS Operator:
    • Tests for the existence of any records in a subquery.
  97. NOT EXISTS Operator:
    • Tests for the non-existence of any records in a subquery.
  98. ANY Operator:
    • Compares a value to any value in a list or a subquery.
  99. ALL Operator:
    • Compares a value to all values in a list or a subquery.
  100. CASE Expression:
    • Performs conditional logic within a SELECT statement.
  101. COALESCE() Function:
    • Returns the first non-NULL value in a list.
  102. NULLIF() Function:
    • Returns NULL if two expressions are equal; otherwise, returns the first expression.
  103. CURRENT_USER Function:
    • Retrieves the current user.
  104. SESSION_USER Function:
    • Retrieves the session user.
  105. DATABASE() Function:
    • Retrieves the current database name.
  106. LIMIT Clause:
    • Specifies the number of rows to return in a result set.
  107. OFFSET Clause:
    • Specifies the number of rows to skip before starting to return rows.
  108. FETCH FIRST n ROWS ONLY Clause:
    • Limits the number of rows returned in a result set.
  109. FETCH NEXT n ROWS ONLY Clause:
    • Retrieves the next n rows from a result set.
  110. FETCH LAST n ROWS ONLY Clause: – Retrieves the last n rows from a result set.
  111. These SQL formulas cover a wide range of functionalities within SQL. If you have specific areas of interest or if you need more examples in a particular category, feel free to let me know!

Leave a Reply

Your email address will not be published. Required fields are marked *