100 SQL Commands — Simple & Unique Explanations

Mou

December 5, 2025


1–10: Basic Data & Structure Commands

  1. SELECT – Pulls data out of a table and shows it to you.
  2. INSERT – Adds a new row of information into a table.
  3. UPDATE – Changes existing data inside a table.
  4. DELETE – Removes rows from a table.
  5. CREATE DATABASE – Makes a brand-new database.
  6. CREATE TABLE – Creates a new table inside a database.
  7. ALTER TABLE – Edits a table’s structure (add/remove/change columns).
  8. DROP TABLE – Completely deletes a table and its data.
  9. TRUNCATE TABLE – Wipes all rows but keeps the table structure.
  10. CREATE INDEX – Builds an index to speed up searches.

11–20: Joins & Grouping

  1. DROP INDEX – Removes an index from a table.
  2. JOIN – Combines data from other tables based on a matching column.
  3. INNER JOIN – Shows only the records matched in both tables.
  4. LEFT JOIN – Shows all records from the left table + matched rows from the right.
  5. RIGHT JOIN – Shows all rows from the right + matched ones from the left.
  6. FULL JOIN – Shows rows from both tables, matched or unmatched.
  7. UNION – Combines results of two queries but removes duplicates.
  8. UNION ALL – Combines results of two queries, keeps duplicates.
  9. GROUP BY – Groups rows that share the same value(s).
  10. HAVING – Filters groups created by GROUP BY.

21–28: Sorting & Basic Functions

  1. ORDER BY – Sorts the output (ASC/DESC).
  2. COUNT – Counts number of rows.
  3. SUM – Adds up a numeric column.
  4. AVG – Finds the average of a numeric column.
  5. MIN – Returns the smallest value.
  6. MAX – Returns the biggest value.
  7. DISTINCT – Shows only unique values.
  8. WHERE – Filters rows based on conditions.

29–41: Conditions & Logical Tools

  1. AND – All conditions must be true.
  2. OR – At least one condition must be true.
  3. NOT – Reverses a condition.
  4. BETWEEN – Selects values inside a specific range.
  5. IN – Matches any value in a given list.
  6. LIKE – Searches using patterns (%, _).
  7. IS NULL – Checks for empty/NULL values.
  8. IS NOT NULL – Checks for non-null values.
  9. EXISTS – Returns true if a subquery has any results.
  10. CASE – Adds conditional logic (if/else) inside a query.
  11. WHEN – Specifies conditions inside CASE.
  12. THEN – Defines what to return when the condition is true.
  13. ELSE – Defines what to return when no conditions match.

42–55: Keys, Constraints & Table Rules

  1. END – Ends the CASE block.
  2. PRIMARY KEY – A column that uniquely identifies each row.
  3. FOREIGN KEY – Connects one table to another using a reference.
  4. CONSTRAINT – A rule applied on a column or table.
  5. DEFAULT – Sets a fallback value if none is provided.
  6. NOT NULL – Makes sure a column never stays empty.
  7. UNIQUE – Ensures all values in a column are different.
  8. CHECK – Applies a condition to limit allowed values.
  9. CASCADE – Automatically applies delete/update to related records.
  10. SET NULL – Turns foreign key values to NULL when parent is deleted.
  11. SET DEFAULT – Replaces foreign key with its default value.
  12. NO ACTION – Prevents delete/update unless dependent rows are handled manually.
  13. RESTRICT – Blocks deletion if related rows exist.
  14. CASE WHEN – Short form of conditional logic inside SELECT.

56–77: Query Enhancers, Pagination & Date Functions

  1. WITH – Creates a temporary result set (CTE).
  2. INTO – Saves SELECT result into a new table.
  3. TOP – Limits number of rows returned.
  4. LIMIT – Restricts the number of rows returned.
  5. OFFSET – Skips a number of rows before starting to return results.
  6. FETCH – Retrieves a specific number of rows.
  7. ROW_NUMBER() – Assigns a unique number to each row.
  8. RANK() – Gives ranking with gaps if ties exist.
  9. DENSE_RANK() – Similar to RANK but without gaps.
  10. NTILE() – Splits rows into N equal-sized groups.
  11. LEAD() – Accesses the next row’s value.
  12. LAG() – Accesses the previous row’s value.
  13. PARTITION BY – Divides data into groups for window functions.
  14. ORDER BY (in windows) – Defines row order within partitions.
  15. ROWS – Sets window frame using row counts.
  16. RANGE – Sets window frame based on value ranges.
  17. CURRENT_TIMESTAMP – Returns current date & time.
  18. CURRENT_DATE – Returns today’s date.
  19. CURRENT_TIME – Returns current time.
  20. DATEADD – Adds time (days, hours, etc.) to a date.
  21. DATEDIFF – Returns difference between two dates.
  22. DATEPART – Extracts a specific part of a date (year, month, etc.).

78–100: Advanced Aggregation, String Functions & Misc

  1. GETDATE – Returns current date & time (like CURRENT_TIMESTAMP).
  2. GROUPING SETS – Lets you group data in multiple ways in one query.
  3. CUBE – Produces every possible combination of groupings.
  4. ROLLUP – Creates subtotals & grand totals automatically.
  5. INTERSECT – Shows common rows in two result sets.
  6. EXCEPT – Shows rows from first query that aren’t in second.
  7. MERGE – Insert, update, or delete based on matching records.
  8. CROSS APPLY – Runs a subquery for each row of a table.
  9. OUTER APPLY – Like CROSS APPLY but includes unmatched rows too.
  10. PIVOT – Converts row values into columns.
  11. UNPIVOT – Converts columns into rows.
  12. COALESCE – Returns first non-null value from a list.
  13. NULLIF – Returns NULL if two values are equal.
  14. IIF – Short form of IF logic (true/false).
  15. CONCAT – Joins two or more strings.
  16. SUBSTRING – Extracts part of a string using positions.
  17. CHARINDEX – Finds position of one string inside another.
  18. REPLACE – Swaps one substring with another inside a string.
  19. LEN – Returns the length of a string.
  20. UPPER – Converts text to uppercase.
  21. LOWER – Converts text to lowercase.
  22. TRIM – Removes spaces from both ends of a string.
  23. ROUND – Rounds a number to desired decimal places.

Section Title

sql interview questions (sql queries)

1. Employees earning more than employee 103 2. Employees with the same job as employee 169 3. Employees earning the minimum salary of any department ... Read more...

100 SQL Commands — Simple & Unique Explanations

1–10: Basic Data & Structure Commands 11–20: Joins & Grouping 21–28: Sorting & Basic Functions 29–41: Conditions & Logical Tools 42–55: Keys, Constraints & Table ... Read more...

SQL Interview Questions & Answers (Advanced – 76 to 100)

76. What is Query Optimization? Query optimization means improving SQL performance so it runs faster. Ways to optimize: Example: 77. What is EXPLAIN in MySQL? ... Read more...

SQL Interview Questions & Answers (Advanced Level – 51 to 75)

51. What is the ACID Property in SQL? ACID ensures reliable transactions. Property Meaning A – Atomicity All steps succeed or all fail. C – ... Read more...

SQL Interview Questions & Answers (Intermediate Level – 26 to 50)

26. What is a Subquery? A subquery is a query inside another query.It is used when you need the result of one query to use ... Read more...

SQL Interview Questions & Answers (Beginner Level – 1 to 25)

1. What is SQL? SQL (Structured Query Language) is a language used to store, manage, and retrieve data from a database. Example: This gets all ... Read more...

Service Portal Interview Questions & Answers (Simple + Unique + Examples)

Welcome to the ultimate guide on Service Portal Interview Questions & Answers. ⭐ SECTION 1: BASICS (FOR FRESHERS) 1. What is Service Portal in ServiceNow? ... Read more...

ITOM Interview Questions & Answers (Simple + Unique + With Examples)

⭐ Section 1: ITOM Basics (For Freshers) ⭐ ITOM Interview Questions & Answers 1. What is ITOM in ServiceNow? Answer:ITOM means managing all IT operations ... Read more...

ITSM Interview Questions & Answers – Full Guide (Part 1 + Part 2 + Part 3)

ITSM Interview Questions & Answers – Full Guide (Part 1 + Part 2 + Part 3) PART 1 – BASIC ITSM QUESTIONS ======================================== What is ... Read more...

Leave a Comment