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

Questions Set 05 (SQL)

The document outlines key SQL concepts, including its definition, usage, and differences between various SQL commands and functions. It addresses specific SQL functionalities like WHERE vs. HAVING, GROUP BY vs. ORDER BY, and the distinctions between COUNT variants. Additionally, it includes practical SQL query examples and scenario-based questions to demonstrate the application of these concepts.

Uploaded by

tolovor302
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)
2 views3 pages

Questions Set 05 (SQL)

The document outlines key SQL concepts, including its definition, usage, and differences between various SQL commands and functions. It addresses specific SQL functionalities like WHERE vs. HAVING, GROUP BY vs. ORDER BY, and the distinctions between COUNT variants. Additionally, it includes practical SQL query examples and scenario-based questions to demonstrate the application of these concepts.

Uploaded by

tolovor302
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

1. What is SQL? Why is it used?

Follow-up Questions:

• Is SQL a programming language?

• Which databases support SQL?

• What are the different categories of SQL commands?

2. What is the difference between WHERE and HAVING?

Follow-up Questions:

• Which clause is executed first?

• Can HAVING be used without GROUP BY?

• Which clause is used with aggregate functions?

3. What is the difference between GROUP BY and ORDER BY?

Follow-up Questions:

• Can both be used in the same query?

• Which clause groups records?

• Which clause sorts records?

4. What is the difference between COUNT(*), COUNT(column), and


COUNT(DISTINCT column)?

Follow-up Questions:

• Which one counts NULL values?

• Give an example of each.

• When would you use COUNT(DISTINCT)?

5. What are Aggregate Functions?

Follow-up Questions:

• Name five aggregate functions.


• Can aggregate functions ignore NULL values?

• Which clause is commonly used with aggregate functions?

6. What is the difference between UNION and UNION ALL?

Follow-up Questions:

• Which one removes duplicate records?

• Which one is faster?

• What conditions must both SELECT statements satisfy?

7. What is the difference between a Subquery and a Join?

Follow-up Questions:

• When would you prefer a Join?

• Can a subquery return multiple rows?

• Can a subquery be nested?

8. What is the difference between CHAR and VARCHAR?

Follow-up Questions:

• Which one saves storage?

• When would you choose CHAR over VARCHAR?

• Give practical examples.

9. Write SQL queries for the following:

• Display all students.

• Display students whose marks are greater than 80.

• Display students sorted by marks in descending order.

• Count the total number of students.

• Find the maximum salary from the Employee table.

Follow-up Questions:
• Explain each query.

• Can you optimize any of them?

10. Scenario-Based Question

Consider the following tables:

Employee(EmpID, Name, DeptID, Salary)

Department(DeptID, DeptName)

Write SQL queries to:

• Display employee name along with department name.

• Find the highest-paid employee.

• Display employees whose salary is above the average salary.

• Count employees department-wise.

• Display departments having more than five employees.

Follow-up Questions:

• Which JOIN will you use?

• Can you solve this using a subquery?

• Which solution is more efficient?

You might also like