0% found this document useful (0 votes)
0 views3 pages

sql_interview_questions_answers (1)

The document provides a collection of SQL interview questions and answers, focusing on basic SQL queries for beginners. It covers fundamental concepts such as SQL commands, the purpose of SELECT, FROM, WHERE clauses, and various SQL functions. Additionally, it explains how to filter, sort, and group data, as well as the use of aliases and aggregate functions.

Uploaded by

Tejaswini MR
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)
0 views3 pages

sql_interview_questions_answers (1)

The document provides a collection of SQL interview questions and answers, focusing on basic SQL queries for beginners. It covers fundamental concepts such as SQL commands, the purpose of SELECT, FROM, WHERE clauses, and various SQL functions. Additionally, it explains how to filter, sort, and group data, as well as the use of aliases and aggregate functions.

Uploaded by

Tejaswini MR
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/ 3

SQL Interview Questions and Answers

1. Basic SQL Queries (Beginner)

1. What is SQL?

SQL (Structured Query Language) is a standard programming language used to manage and

manipulate relational databases. It allows users to create, read, update, and delete data.

2. What are the different types of SQL commands?

- DDL (Data Definition Language): CREATE, ALTER, DROP

- DML (Data Manipulation Language): SELECT, INSERT, UPDATE, DELETE

- DCL (Data Control Language): GRANT, REVOKE

- TCL (Transaction Control Language): COMMIT, ROLLBACK, SAVEPOINT

3. Explain the purpose of SELECT, FROM, WHERE clauses.

- SELECT: Specifies the columns to retrieve.

- FROM: Specifies the table to query.

- WHERE: Filters records based on a condition.

4. How do you retrieve all columns and rows from a table?

SELECT * FROM table_name;

5. How do you filter rows based on a specific condition?

SELECT * FROM table_name WHERE column = 'value';

6. Explain the use of AND and OR in the WHERE clause.


- AND: All conditions must be true.

- OR: At least one condition must be true.

7. How do you sort the result set?

SELECT * FROM table_name ORDER BY column ASC/DESC;

8. How do you retrieve distinct values?

SELECT DISTINCT column FROM table_name;

9. What are aggregate functions?

COUNT(), SUM(), AVG(), MIN(), MAX()

10. How do you group rows and apply an aggregate function?

SELECT column, COUNT(*) FROM table_name GROUP BY column;

11. What is the purpose of HAVING?

HAVING filters groups after aggregation, whereas WHERE filters rows before grouping.

12. How do you limit rows returned?

MySQL/PostgreSQL: LIMIT 10

SQL Server: TOP 10

Oracle: WHERE ROWNUM <= 10

13. What are aliases?

Temporary names for columns/tables.

SELECT column AS alias FROM table_name;


... [Due to space, only part shown here; will include full content in PDF]

You might also like