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

Top 20 SQL Interview Questions Fresher Mohd Daoud

The document lists the top 20 SQL interview questions for freshers, covering fundamental concepts such as SQL commands, data retrieval, primary and foreign keys, and various SQL operations like JOINs and subqueries. It provides example queries for practical understanding and highlights key differences between commands like DELETE, TRUNCATE, and DROP. Overall, it serves as a comprehensive guide for beginners preparing for SQL interviews.

Uploaded by

derotav936
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)
7 views2 pages

Top 20 SQL Interview Questions Fresher Mohd Daoud

The document lists the top 20 SQL interview questions for freshers, covering fundamental concepts such as SQL commands, data retrieval, primary and foreign keys, and various SQL operations like JOINs and subqueries. It provides example queries for practical understanding and highlights key differences between commands like DELETE, TRUNCATE, and DROP. Overall, it serves as a comprehensive guide for beginners preparing for SQL interviews.

Uploaded by

derotav936
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

Top 20 SQL Interview Questions for Freshers

1. What is SQL?

SQL (Structured Query Language) is used to store, manipulate, and retrieve data from relational

databases.

2. What are the different types of SQL commands?

DDL (CREATE, ALTER), DML (INSERT, UPDATE), DQL (SELECT), DCL (GRANT), TCL

(COMMIT, ROLLBACK).

3. Retrieve all data from a table

SELECT * FROM employees;

4. Get only specific columns

SELECT name, salary FROM employees;

5. Find unique values

SELECT DISTINCT department FROM employees;

6. What is a Primary Key?

A primary key uniquely identifies each record in a table and cannot be null or duplicated.

7. What is a Foreign Key?

A foreign key links one table to another and maintains referential integrity.

8. Filter data using WHERE

SELECT * FROM employees WHERE salary > 30000;

9. Sort data

SELECT * FROM employees ORDER BY name ASC;

10. Count rows

SELECT COUNT(*) FROM employees;

11. WHERE vs HAVING


WHERE filters rows before grouping; HAVING filters after grouping.

12. Group data

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

13. Pattern matching with LIKE

SELECT * FROM employees WHERE name LIKE 'A%';

14. Find NULL values

SELECT * FROM employees WHERE manager_id IS NULL;

15. What is INNER JOIN?

Returns records that match in both tables.

INNER JOIN Example

SELECT e.name, d.name FROM employees e INNER JOIN departments d ON e.dept_id = d.id;

16. DELETE vs TRUNCATE vs DROP

DELETE: Conditional remove (rollback allowed)

TRUNCATE: Removes all rows (no rollback)

DROP: Deletes table structure.

17. Update a record

UPDATE employees SET salary = 40000 WHERE id = 1;

18. Insert a record

INSERT INTO employees (name, salary, department) VALUES ('Daoud', 35000, 'IT');

19. Delete specific rows

DELETE FROM employees WHERE department = 'HR';

20. What is a subquery?

A subquery is a query inside another query.

Example: SELECT name FROM employees WHERE salary > (SELECT AVG(salary) FROM

employees);

You might also like