SQL Flashcards
1
Q
SQL FROM
A
- Specifies which tables you are using
2
Q
SQL WHERE
A
- Specifies which rows you are including (SELECTION)
3
Q
SQL SELECT
A
- Specifies which columns you are including (PROJECTION)
4
Q
SQL LIKE
A
- % stands for 0 or more arbitrary characters
- _ stands for a single arbitrary character
5
Q
SQL Comparisons Involving NULL
A
- Any comparison involving NULL using standard operators is always False
- Use “IS” to check for NULL
6
Q
SQL COUNT(*) vs COUNT(attribute)
A
- COUNT(*) counts the number of tuples in a result
- COUNT(attribute) counts the number of non-NULL values of an attribute in a result
7
Q
SQL DISTINCT
A
- Removes duplicates
8
Q
SQL GROUP BY
A
- Group together tuples with a common value
- Apply aggregate functions to the tuples in each subgroup
9
Q
SQL HAVING
A
- Allows us to apply a selection condition in the subgroups produced through the GROUP BY clause
10
Q
SQL Difference between WHERE and HAVING
A
- A WHERE clause is applied before grouping
- A HAVING clause is applied after grouping
11
Q
SQL ORDER BY
A
- Sorts the tuples in the result by one or more attributes
- Ascending by default, use DESC for descending
12
Q
SQL Aggregate Functions
A
- Perform a computation on a collection of values on an attribute
- Can be included in the SELECT clause
- Examples: MIN, MAX, AVG, SUM, COUNT
- Generally cannot mix aggregate functions with column names in the SELECT clause
13
Q
SQL Subqueries
A
- Allows us to use the result of one query in the evaluation of another query
14
Q
SQL Set Membership
A
- Subqueries can be used to test for set membership in conjunction with the IN and NOT IN operators
15
Q
SQL Set Operations
A
- UNION
- INTERSECTION
- EXCEPT (set difference)