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

SQL Interview Concepts

The document outlines essential SQL interview concepts and queries, including SELECT, INSERT, UPDATE, DELETE, and JOIN operations. It also covers GROUP BY, HAVING, subqueries, aggregate functions, indexes, and normalization principles. Each concept is illustrated with examples to demonstrate their usage in SQL.
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)
3 views2 pages

SQL Interview Concepts

The document outlines essential SQL interview concepts and queries, including SELECT, INSERT, UPDATE, DELETE, and JOIN operations. It also covers GROUP BY, HAVING, subqueries, aggregate functions, indexes, and normalization principles. Each concept is illustrated with examples to demonstrate their usage in SQL.
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

SQL Interview Concepts & Queries

1. SELECT Query

Used to fetch data from one or more tables.

Example:

SELECT name, age FROM employees WHERE age > 30;

2. INSERT Query

Used to add new records to a table.

Example:

INSERT INTO employees (name, age, department) VALUES ('John', 28, 'Sales');

3. UPDATE Query

Used to modify existing data in a table.

Example:

UPDATE employees SET age = 29 WHERE name = 'John';

4. DELETE Query

Used to remove data from a table.

Example:

DELETE FROM employees WHERE age < 25;

5. JOINs

Used to combine rows from two or more tables based on a related column.

- INNER JOIN: Returns matching rows.

- LEFT JOIN: All rows from left, matching from right.

Example:

SELECT e.name, d.dept_name FROM employees e

JOIN departments d ON e.dept_id = d.id;


SQL Interview Concepts & Queries

6. GROUP BY and HAVING

GROUP BY groups rows with the same values; HAVING filters grouped rows.

Example:

SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5;

7. Subqueries

A query inside another query. Can be used in WHERE, FROM, or SELECT.

Example:

SELECT name FROM employees WHERE dept_id = (SELECT id FROM departments WHERE dept_name =

'IT');

8. Aggregate Functions

Functions like COUNT(), SUM(), AVG(), MIN(), MAX() for calculations on sets.

Example:

SELECT AVG(salary) FROM employees;

9. Indexes

Improve query performance by allowing faster data retrieval.

Example:

CREATE INDEX idx_name ON employees(name);

10. Normalization

Process of organizing data to reduce redundancy. Key forms: 1NF, 2NF, 3NF.

- 1NF: Atomic columns

- 2NF: Remove partial dependency

- 3NF: Remove transitive dependency

You might also like