What does the SELECT statement do in SQL?
It specifies which columns to display in the result set.
What clause specifies which table to retrieve data from?
FROM clause.
Which clause filters rows based on conditions?
WHERE clause.
How do you sort query results?
Using ORDER BY followed by column name(s) and ASC or DESC.
What is the purpose of GROUP BY?
To aggregate data across rows that share a common value in one or more columns.
What is the difference between WHERE and HAVING?
WHERE filters rows before aggregation; HAVING filters groups after aggregation.
What does COUNT(*) do?
Counts all rows in the result set including duplicates and NULLs.
How do you count distinct values in a column?
COUNT(DISTINCT column_name).
Which SQL function returns the average of a numeric column?
AVG().
Which function returns the sum of all values in a column?
SUM().
Which function returns the largest value in a column?
MAX().
Which function returns the smallest value in a column?
MIN().
What keyword removes duplicate rows from a query result?
DISTINCT.
What is the purpose of the AS keyword?
To rename a column or table with an alias.
What are the main types of JOINs in SQL?
INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN
What does an INNER JOIN return?
Rows with matching values in both tables.
What does a LEFT JOIN return?
All rows from the left table and matched rows from the right; unmatched right values become NULL.
What does a RIGHT JOIN return?
All rows from the right table and matched rows from the left; unmatched left values become NULL.
What does a FULL OUTER JOIN return?
All rows when there is a match in either left or right table
How do you combine results of two queries?
Using UNION or UNION ALL.
What is the difference between UNION and UNION ALL?
UNION removes duplicates
What is a subquery?
A query nested inside another query.
What does the IN operator do?
Tests whether a value matches any value in a list or subquery.
What does BETWEEN do?
Filters values within a given range (inclusive).