
SQL Basics
SELECT, WHERE, JOIN types, GROUP BY, HAVING, aggregate functions, subqueries, indexes, and normalization.
Cards (24)
- 1Front
What does the SELECT statement do in SQL?
BackIt retrieves data from one or more tables, specifying which columns to return in the result set.
- 2Front
What is the purpose of SELECT DISTINCT?
BackIt removes duplicate rows from the result set, returning only unique values for the specified columns.
- 3Front
What does the WHERE clause do in a SQL query?
BackIt filters rows returned by a query, including only rows that satisfy the specified condition.
- 4Front
What is the difference between WHERE and HAVING in SQL?
BackWHERE filters rows before grouping; HAVING filters groups after GROUP BY has been applied.
- 5Front
What does an INNER JOIN return?
BackOnly the rows where there is a matching value in both joined tables.
- 6Front
What does a LEFT JOIN (LEFT OUTER JOIN) return?
BackAll rows from the left table and matching rows from the right table; non-matching right-table columns return NULL.
- 7Front
What does a RIGHT JOIN return?
BackAll rows from the right table and matching rows from the left table; non-matching left-table columns return NULL.
- 8Front
What does a FULL OUTER JOIN return?
BackAll rows from both tables, with NULLs where there is no match on either side.
- 9Front
What does a CROSS JOIN produce?
BackThe Cartesian product of two tables — every row of the first table combined with every row of the second table.
- 10Front
What is the purpose of GROUP BY in SQL?
BackIt groups rows that share the same values in specified columns so aggregate functions can be applied to each group.
- 11Front
What rule must columns follow when GROUP BY is used?
BackEvery column in the SELECT list must either appear in the GROUP BY clause or be inside an aggregate function.
- 12Front
What does the COUNT() aggregate function return?
BackThe number of rows (or non-NULL values for a specific column) in a group or result set.
- 13Front
What does the SUM() aggregate function do?
BackIt returns the total sum of all non-NULL numeric values in the specified column.
- 14Front
What is the difference between AVG() and SUM()?
BackSUM() returns the total of all values; AVG() returns the arithmetic mean (SUM divided by COUNT of non-NULL values).
- 15Front
What do the MIN() and MAX() aggregate functions return?
BackMIN() returns the smallest value; MAX() returns the largest value in the specified column.
- 16Front
What is a subquery in SQL?
BackA query nested inside another query, used in SELECT, FROM, or WHERE clauses to provide intermediate results.
- 17Front
What is a correlated subquery?
BackA subquery that references a column from the outer query, causing it to be evaluated once per row of the outer query.
- 18Front
What is the difference between IN and EXISTS when using subqueries?
BackIN checks whether a value matches any value in a list returned by the subquery; EXISTS checks whether the subquery returns at least one row.
- 19Front
What is a SQL index?
BackA database object that improves the speed of data retrieval by creating a sorted data structure on one or more columns.
- 20Front
What is the trade-off of adding indexes to a table?
BackIndexes speed up reads but slow down INSERT, UPDATE, and DELETE operations and consume additional storage space.
- 21Front
What is database normalization?
BackThe process of organizing a database to reduce data redundancy and improve data integrity by dividing data into related tables.
- 22Front
What are the requirements for First Normal Form (1NF)?
BackEach column must contain atomic (indivisible) values, each column must hold values of a single type, and each row must be unique.
- 23Front
What additional requirement does Second Normal Form (2NF) add over 1NF?
BackThe table must be in 1NF, and every non-key attribute must be fully functionally dependent on the entire primary key (no partial dependencies).
- 24Front
What additional requirement does Third Normal Form (3NF) add over 2NF?
BackThe table must be in 2NF, and no non-key attribute should depend on another non-key attribute (no transitive dependencies).
Study this deck free
Create a free account to flip through these flashcards, quiz yourself, play match, and track what you've mastered — or fork the deck to make it your own.