Live Lecure Materials Week 11 Flashcards

(20 cards)

1
Q

You can sort results using the

A

ORDER BY clause

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

You can sort in __________ (___) or __________ (____) order

A

Ascending (ASC) or descending (DSC)

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

Count(*), COUNT({Name}), SUM, AVG, MIN, MAX are examples of

A

Aggregate functions

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

Count(*)

A

Counts the number of rows in a table

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

Count({Name})

A

Counts rows where the column name is not null

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

Min

A

Calculates the minimum value of all values

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

Max

A

Calculates the maximum of all values

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

Aggregate functions allow you to view a ______ piece of data from ________ pieces of data

A

single, multiple

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

Most normal functions operate on a ______ ___, most aggregate functions operate on ________ ____

A

single row, multiple rows

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

Put these in order for a SUM function

Sum( OrderTotal )
FROM
AS OrderSum
RETAIL_ORDER
SELECT

A

SELECT SUM( OrderTotal ) AS OrderSum FROM RETAIL_ORDER

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

Clause that specifies which rows will be used to determine the groups

A

WHERE

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

Clause that specifies which groups will be used in the final result

A

HAVING

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

T/F - The WHERE clause should be placed before the GROUP BY clause

A

True

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

T/F - HAVING applies before WHERE

A

False

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

T/F - Rows can be grouped by more than one column

A

True

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

Groups rows that have the same values into summary rows

17
Q

If there is a column in the SELECT clause that is not used by any other functions in a statement, it must

A

be used in the group by clause. Otherwise the query will return an error.

18
Q

1 of the 2 limits to built-in aggregate functions

A

You cannot combine table column names with aggregate functions

19
Q

2 of the 2 limits to SQL built in functions

A

You cannot use aggregate functions in the WHERE clause

20
Q

SELECT OrderNumber, SKU
FROM ORDER_ITEM
WHERE (Quantity * Price) <> ExtendedPrice
ORDER BY OrderNumber, SKU;

This returns no results, why?

A

There are no rows where Quantity * Price does not equal ExtendedPrice. It is working correctly.