Fundamentals Flashcards
(18 cards)
What is the function of the SELECT
keyword?
The SELECT
keyword is used to query data from tables
List three possible SELECT
selector types.
-
*
selects all columns - A list of column names, separated by a
,
- Expressions & literal values
How would you concatenate and return the values of two or more columns?
Split column names with the concatenation operator ||
(double pipe).
In which order does a basic SELECT
statement evaluate?
The FROM
value is evaluated before the SELECT
value.
When should you omit FROM
from a select statement? Provide an example.
FROM
can be omitted when no data is being queried from a table.
An example of this is when SELECT
is used to evaluate a mathematical expression, i.e.: SELECT 5 * 3
returns an unnamed column with a single row value of 15.
What is the function of the DISTINCT
clause?
The DISTINCT
clause selects distinct rows.
What is the function of the ORDER BY
clause?
The ORDER BY
clause sorts selected rows.
What is the function of the WHERE
clause?
The WHERE
clause filters selected rows.
What is the function of the LIMIT
and FETCH
clauses?
The LIMIT
and FETCH
clauses select a subset of rows.
What is the function of the GROUP BY
clause?
The GROUP BY
clause groups rows by a given value.
What is the function of the HAVING
clause?
The HAVING
clause filters grouped rows.
What is the function of INNER JOIN
, LEFT JOIN
, FULL OUTER JOIN
, and CROSS JOIN
?
INNER JOIN
, LEFT JOIN
, FULL OUTER JOIN
, and CROSS JOIN
connect tables together.
What are the UNION
, INTERSECT
, and EXCEPT
clauses?
The UNION
, INTERSECT
, and EXCEPT
clauses are set operations.
What is the function of column aliases?
Column aliases assign temporary name to columns in queries.
What is the lifespan of column aliases?
Column aliases exist during the execution of the query.
What keyword is used to denote a column alias? What can be used instead of the keyword?
The keyword used to denote a column alias is AS
. It can be omitted for a space between the selector and the alias.
With what types of selectors can aliases be used?
Aliases can be used with all types of selectors, including expressions.
How would you format aliases that contain spaces?
Aliases with spaces should be wrapped in double quotes.