SQL Flashcards

1
Q

How do you subset or filter data in SQL?

A

To subset or filter data in SQL, we use WHERE and HAVING clauses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between a WHERE clause and a HAVING clause in SQL?

A

WHERE:
WHERE clause operates on row data.
In the WHERE clause, the filter occurs before any groupings are made.
Aggregate functions cannot be used.

HAVING:
The HAVING clause operates on aggregated data.
HAVING is used to filter values from a group.
Aggregate functions can be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How are Union, Intersect, and Except used in SQL?

A

The Union operator combines the output of two or more SELECT statements, giving us unique results from all SELECT statements - no duplicates.

The Intersect operator returns the common records that are the results of 2 or more SELECT statements.

The Except operator returns the uncommon records that are the results of 2 or more SELECT statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Subquery in SQL?

A

A Subquery in SQL is a query within another query. It is also known as a nested query or an inner query. Subqueries are used to enhance the data to be queried by the main query.

It is of two types - Correlated and Non-Correlated Query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly