SELECT, Joins, Unions - Week 2
Which ORDER BY clause causes 10 rows to be retrieved from the result set, starting with the 20th row? a. ORDER BY InvoiceTotal DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS b. ORDER BY InvoiceTotal DESC OFFSET 10 ROWS FETCH FIRST 20 ROWS c. ORDER BY InvoiceTotal DESC OFFSET 20 ROWS FETCH NEXT 10 ROWS d. ORDER BY InvoiceTotal DESC OFFSET 20 ROWS FETCH FIRST 10 ROWS
ORDER BY InvoiceTotal DESC OFFSET 20 ROWS FETCH NEXT 10 ROWS
The search conditions of a WHERE clause consists of one or more a. numeric expressions b. string expressions c. Boolean expressions d. none of the above
Boolean expressions
________________ names can be used when you want to assign a temporary name to a table. a. Correlation b. Object c. Qualified d. Table
Correlation
Which clause specifies the number of rows that should be retrieved after skipping the specified number of rows? a. FIRST b. NEXT c. OFFSET d. FETCH
FETCH
Correlation names are temporary table names assigned in which clause? a. WHERE b. FROM c. ORDER BY d. ON
FROM
Which clause of the SELECT statement names the table that contains the data to be retrieved? a. ORDER BY b. FROM c. WHERE d. SELECT
FROM
Which of the following is not a valid column alias name? a. Total b. Total Sales c. TotalSales d. "Total Sales"
Total Sales
A join that joins a table with itself is called a. a self-join b. a U-join c. an outer join d. an inner join
a self-join
A string expression can consist of a. a combination of character columns and literal values b. one or more literal values c. one or more character columns d. all of the above
all of the above
A union combines the rows from two or more what? a. SELECT statements b. result tables c. queries d. all of the above
all of the above
Which keyword lets you control the number of rows that are returned by a query? a. TOP b. DISTINCT c. ALL d. all of the above
all of the above
A combination of column names and operators that evaluate to a single value is called a. a view b. an expression c. a predicate d. a query
an expression
When you need to code multiple conditions in a join, it's best to a. code only join conditions in the WHERE clause b. code all conditions in the ON clause c. code all conditions in the WHERE clause d. code only join conditions in the ON clause
code only join conditions in the ON clause
When you code an ORDER BY clause, you can specify a a. column name, alias, expression, or column number b. column name, alias, or expression c. column name or expression d. column name or alias
column name, alias, expression, or column number
In most cases, the join condition of an inner join compares the primary key of one table to the ________________ key of another table. a. foreign b. unique c. primary d. SELECT
foreign
If you want to join all of the rows in the first table of a select statement with the just matched rows in a second table, you use what kind of join? a. right outer b. full outer c. cross d. left outer
left outer
Which of the following is not a reason for using the explicit syntax instead of the implicit syntax for inner joins? The explicit syntax a. lets you separate the join and search conditions b. lets you combine the join and search conditions c. is easier to read and understand d. lets you combine inner and outer joins
lets you combine the join and search conditions
Code example: SELECT VendorName, InvoiceNumber FROM Invoices LEFT JOIN Vendors ON Invoices.VendorID = Vendors.VendorID; If the LEFT keyword is replaced with the RIGHT keyword, the total number of rows that returned must equal a. the number of rows in the Invoices table b. the number of rows in the Vendors table c. the number of rows in the Invoices table plus the number of rows in the Vendors table d. none of the above
none of the above
A full outer join includes rows that satisfy the join condition, plus a. rows in the left table that don't satisfy the join condition b. rows in the right table that don't satisfy the join condition c. the Cartesian product of the two tables d. rows in both tables that don't satisfy the join conditions
rows in both tables that don't satisfy the join condition
Code example: SELECT VendorName, InvoiceNumber FROM Invoices LEFT JOIN Vendors ON Invoices.VendorID = Vendors.VendorID; The total number of rows returned by this query must equal a. the number of rows in the Invoices table b. the number of rows in the Vendors table c. the number of rows in the Invoices table plus the number of rows in the Vendors table d. none of the above
the number of rows in the Invoices table