SQL Quiz Flashcards

(25 cards)

1
Q

Which SQL clause filters rows in a dataset?

A

WHERE clause

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

What does the SELECT clause do in SQL?

A

Specifies which columns to return

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

Which SQL clause limits results to only rows meeting certain conditions?

A

WHERE

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

What SQL clause would you use to find customers who purchased in the last month?

A

WHERE

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

Which naming convention is SQL best practice?

A

lowercase or snake_case

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

Why is snake_case preferred in SQL?

A

It improves readability and avoids case-sensitivity issues

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

What is camelCase commonly used for?

A

Programming variables, not SQL column names

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

What type of case is ‘WebTrafficAnalytics’?

A

Camel case

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

What can be removed from a SQL query without breaking it?

A

Backticks around identifiers

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

When should backticks be used in SQL?

A

Only if names contain spaces, special characters, or reserved keywords

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

What does SELECT * mean?

A

Return all columns in a table

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

Why avoid SELECT * in production queries?

A

It reduces efficiency and can expose unnecessary data

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

How can you filter data for the last month?

A

Use WHERE with a date function like DATE_SUB

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

What’s the difference between WHERE and HAVING?

A

WHERE filters rows before aggregation; HAVING filters after

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

Which clause defines columns returned?

A

SELECT

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

What does the FROM clause specify in SQL?

A

The table from which to retrieve data.

17
Q

What is the purpose of the WHERE clause?

A

To filter rows that meet specific conditions.

18
Q

What mistake occurs if you write FROM Grade instead of FROM Students?

A

You are trying to select from a column, not a table.

19
Q

Which SQL statement returns only elementary school students?

A

SELECT * FROM Students WHERE Grade = ‘elementary’;

20
Q

What does SELECT * mean?

A

Return all columns from the specified table.

21
Q

How do you filter results where Grade equals ‘elementary’?

A

Use WHERE Grade = ‘elementary’;

22
Q

Why must ‘elementary’ be in quotes?

A

Because it is a text string (not a numeric or column name).

23
Q

What happens if you omit the WHERE condition?

A

All rows in the table are returned.

24
Q

What is the correct order of SQL clauses?

A

SELECT → FROM → WHERE

25
How would you count only elementary students?
SELECT COUNT(*) FROM Students WHERE Grade = 'elementary';