How can you reference aliased columns in the WHERE clause?
By wrapping the query as an inline view.
What is the address of O’Reilly Media, Inc.?
1005 Gravenstein Highway North, Sebastopol, CA 95472.
1/215
p.28
Working with Multiple Tables

How can you reference aliased columns in the WHERE clause?

By wrapping the query as an inline view.

p.20
Metadata Queries

What is the address of O’Reilly Media, Inc.?

1005 Gravenstein Highway North, Sebastopol, CA 95472.

p.19
Advanced SQL Techniques

What is required by the ANSI SQL standard for inline views?

They must be given table aliases.

p.18
SQL Basics

What typographical convention is used to indicate SQL keywords within text?

UPPERCASE.

p.29
Retrieving Records

What is an inline view?

A temporary result set that can be aliased for use in a query.

p.15
Advanced SQL Techniques

What is the purpose of the new recipe in Chapter 6?

To help match data by the sound of the text.

p.18
SQL Basics

What is the preferred case for SQL statements according to the book?

lowercase for both keywords and user-specified identifiers.

p.18
SQL Basics

What case is used for all queries in code examples?

lowercase.

p.20
Metadata Queries

Who should comments and questions about the book be addressed to?

The publisher: O’Reilly Media, Inc.

p.24
Retrieving Records

What is the focus of Chapter 1?

Basic SELECT statements.

p.21
Advanced SQL Techniques

What role did Georgia play in the author's writing process?

She provided support throughout the writing of the book.

p.20
Metadata Queries

What is the contact number for O’Reilly Media in the United States or Canada?

800-998-9938.

p.18
SQL Basics

What is the example SQL query provided in the text?

select empno, ename from emp;

p.31
Advanced SQL Techniques

What happens if you omit the ELSE clause in a CASE expression?

The CASE expression will return NULL for any row that does not satisfy the test condition.

p.8
Retrieving Records

Which section covers finding rows that satisfy multiple conditions?

1.3 Finding Rows That Satisfy Multiple Conditions.

p.21
Advanced SQL Techniques

What unique qualification does Jonathan Gennick have that benefits his editing?

He is an experienced database administrator (DBA).

p.31
Retrieving Records

What SQL command is used to limit rows in MySQL and PostgreSQL?

LIMIT.

p.25
Retrieving Records

What is a potential problem with using SELECT * in SQL queries?

It can lead to unexpected results if the query returns a different set of columns than expected.

p.26
Retrieving Records

What SQL clause is used to filter records based on specific conditions?

WHERE clause.

p.26
Retrieving Records

What does the presence of parentheses in a SQL query do?

It causes conditions within them to be evaluated together.

p.27
Retrieving Records

What is the purpose of using the AS keyword in SQL?

To change the names of the columns returned by a query to make them more readable and understandable.

p.14
SQL Basics

What does this book aim to expand for SQL users?

Users' tool boxes and understanding of SQL capabilities.

p.26
Retrieving Records

What is the purpose of using AND and OR in a SQL query?

To combine multiple conditions for filtering records.

p.8
Retrieving Records

What section discusses retrieving all rows and columns from a table?

1.1 Retrieving All Rows and Columns from a Table.

p.5
Metadata Queries

What should users ensure regarding code samples in the SQL Cookbook?

That their use complies with open source licenses or intellectual property rights.

p.27
Retrieving Records

What is the benefit of using meaningful names for columns in query results?

It makes the results more readable and understandable for users.

p.14
Advanced SQL Techniques

What are Common Table Expressions (CTEs) used for?

To solve practical limitations of SQL.

p.32
Retrieving Records

What is the purpose of the ROWNUM function in Oracle?

It assigns an increasing number to each row returned, starting from one.

p.15
Advanced SQL Techniques

What new material is introduced in Chapters 6 and 7?

New data analysis applications, including recipes about the median absolute deviation and Benford’s law.

p.31
Advanced SQL Techniques

What does the CASE expression do in SQL?

It performs conditional logic directly in a SELECT statement.

p.15
SQL Basics

Who is this book intended for?

Any SQL user who wants to enhance their queries, including data engineers, data scientists, and BI professionals.

p.29
String Manipulation in SQL

What SQL query would you use to concatenate employee names and their jobs from the EMP table?

SELECT ename || ' WORKS AS A ' || job AS msg FROM emp WHERE deptno = 10.

p.31
Advanced SQL Techniques

What alias is given to the result of the CASE expression in the provided solution?

STATUS.

p.19
Advanced SQL Techniques

Which SQL vendor allows the omission of table aliases for inline views?

Oracle.

p.32
Retrieving Records

How does Oracle restrict the number of rows returned in a query?

By using ROWNUM in the WHERE clause.

p.24
Retrieving Records

What happens if no WHERE clause is specified in a SELECT statement?

Every row will be returned.

p.19
Advanced SQL Techniques

What does the letter X represent in the query 'select job, sal from (select job, max(sal) sal from emp group by job) x;'?

The name of the 'table' returned by the subquery in the FROM clause.

p.22
Advanced SQL Techniques

What did Olivier Pomel contribute to the book?

A DB2 solution for creating delimited lists from rows.

p.32
Retrieving Records

What happens when you use ROWNUM <= 5 in Oracle?

Oracle fetches rows and returns them until it reaches five rows.

p.9
Working with Multiple Tables

How can you find rows in common between two tables?

By using intersection queries or inner joins.

p.25
Retrieving Records

What SQL command would you use to view all employees assigned to department number 10?

SELECT * FROM emp WHERE deptno = 10;

p.9
Working with Multiple Tables

What is a Cartesian product?

A result set that combines every row from one table with every row from another table.

p.29
String Manipulation in SQL

Which databases use the double vertical bar for concatenation?

DB2, Oracle, and PostgreSQL.

p.21
Advanced SQL Techniques

Who does the author thank for reminding him of the importance of life outside of work?

His brother, Joe.

p.23
Advanced SQL Techniques

What is the author's name?

Anthony Molinaro.

p.27
Retrieving Records

What does aliasing refer to in SQL?

The process of giving new names to columns returned by a query using the AS keyword.

p.5
Metadata Queries

What is the purpose of the SQL Cookbook?

To provide educational, business, or sales promotional use.

p.17
Working with Multiple Tables

What does the number following the 'T' in the pivot tables signify?

The number of rows in each table, starting from 1.

p.21
Advanced SQL Techniques

Who is credited with going above and beyond as an editor for the book?

Jonathan Gennick.

p.20
Metadata Queries

Where can you find errata and additional information about the book?

On the book's web page: https://oreil.ly/sql-ckbk-2e.

p.24
Retrieving Records

Why is it easier to use SELECT * in ad hoc queries?

It retrieves all columns without listing them individually.

p.19
Advanced SQL Techniques

What kind of names are typically given to aliases on inline views?

Trivial names such as X, Y, Z, TMP1, and TMP2.

p.14
Advanced SQL Techniques

What are window functions?

A feature in SQL that allows for advanced data analysis.

p.32
Retrieving Records

Why is using ROWNUM = 5 problematic in Oracle?

Because it will never return the fifth row; it discards rows that don't meet the criteria.

p.32
Retrieving Records

What is a common mistake made by Oracle developers regarding ROWNUM?

Attempting to return a specific row using an equality condition with ROWNUM.

p.11
Date and Time Functions

What is the purpose of section 8.3?

Determining the Number of Business Days Between Two Dates.

p.25
Retrieving Records

What is an example of a query that finds employees in department 10 or those who earn a commission?

SELECT * FROM emp WHERE deptno = 10 OR commission IS NOT NULL;

p.25
Retrieving Records

How would you find employees in department 20 who earn at most $2,000?

By adding a condition in the WHERE clause: AND deptno = 20 AND salary <= 2000.

p.10
String Manipulation in SQL

What does it mean to determine whether a string is alphanumeric?

To check if the string contains only letters and numbers.

p.13
String Manipulation in SQL

What is a technique for searching mixed alphanumeric strings?

Using pattern matching functions.

p.30
Advanced SQL Techniques

What message is returned for employees earning $2,000 or less?

UNDERPAID.

p.16
Working with Multiple Tables

What is the many-to-one relationship in the context of these tables?

Many employees belong to one department.

p.12
Advanced SQL Techniques

What are Knight values in SQL?

Specific values used in certain algorithms or calculations, often related to game theory or optimization.

p.27
Retrieving Records

Why is it important to specify columns in the SELECT clause?

To ensure that no extraneous data is returned, which saves time and resources, especially over a network.

p.29
String Manipulation in SQL

How can you concatenate values from multiple columns in SQL?

By using the built-in concatenation function or operator provided by the DBMS.

p.22
Advanced SQL Techniques

Who is thanked for the book 'Mastering Oracle SQL'?

Sanjay Mishra.

p.17
Working with Multiple Tables

What are the names of the pivot tables mentioned in the book?

T1, T10, T100, and T500.

p.14
Advanced SQL Techniques

What type of analysis can SQL be used for according to the book?

Statistical analysis.

p.15
SQL Basics

What theoretical aspects does this book not cover?

Database design, theory behind SQL, and extensions for data types like XML and JSON.

p.17
Working with Multiple Tables

What is the purpose of the pivot tables?

To facilitate the creation of a series of rows for queries.

p.32
Retrieving Records

What SQL command is used in SQL Server to limit the number of rows returned?

The TOP keyword.

p.21
Advanced SQL Techniques

What famous quote by Isaac Newton is referenced in the acknowledgments?

“If I have seen a little further it is by standing on the shoulders of giants.”

p.31
Retrieving Records

What is the SQL command to fetch the first 5 rows from the 'emp' table in DB2?

SELECT * FROM emp FETCH FIRST 5 ROWS ONLY.

p.34
Advanced SQL Techniques

What is the difference between using a function and a numeric constant in the ORDER BY clause?

A function sorts based on its evaluated result for each row, while a numeric constant sorts based on the column's ordinal position.

p.11
Date and Time Functions

What does section 8.1 cover?

Adding and Subtracting Days, Months, and Years.

p.10
String Manipulation in SQL

What is the focus of section 6 in the document?

Working with Strings.

p.11
Working with Ranges

What does section 10.1 address?

Locating a Range of Consecutive Values.

p.13
Advanced SQL Techniques

Which clause in Oracle is used for transposing a result set?

MODEL clause.

p.13
Numerical Operations in SQL

How can whole numbers be converted to binary in Oracle?

Using conversion functions.

p.13
Advanced SQL Techniques

What is the purpose of pivoting a ranked result set?

To display data in a more readable format.

p.16
Working with Multiple Tables

How many rows does the DEPT table contain?

4 rows.

p.16
Retrieving Records

What SQL command is used to display all records from the DEPT table?

select * from dept;

p.29
Retrieving Records

What is the purpose of using an alias in a WHERE clause?

To reference columns that may not have well-named identifiers.

p.28
Retrieving Records

Why does referencing an aliased column in the WHERE clause fail?

Because the WHERE clause is evaluated before the SELECT clause, so aliases do not exist yet.

p.5
Metadata Queries

Which company published the SQL Cookbook?

O’Reilly Media, Inc.

p.31
Advanced SQL Techniques

How can you provide a more readable result set when using the CASE expression?

By providing an alias for the CASE expression.

p.8
Retrieving Records

What is the first topic covered in the table of contents?

Retrieving Records.

p.28
Advanced SQL Techniques

What are some scenarios where you need to use an inline view?

When referencing aggregate functions, scalar subqueries, windowing functions, or aliases in the WHERE clause.

p.34
Advanced SQL Techniques

What function is used in Oracle to generate random values?

DBMS_RANDOM.VALUE.

p.18
SQL Basics

What is the book's approach to coding style?

Use whatever coding style you prefer or what your project requires.

p.31
Retrieving Records

How can you limit the number of rows returned in a DB2 query?

By using the FETCH FIRST clause.

p.34
Advanced SQL Techniques

What is the SQL Server function used to return a random result set?

NEWID.

p.17
Working with Multiple Tables

What is the purpose of using the T1 table in the book?

To provide a single row instead of using partial queries for clarity.

p.17
Working with Multiple Tables

How does the T1 table compare to Oracle's DUAL table?

It serves a similar purpose but is standardized across all implementations discussed in the book.

p.22
Advanced SQL Techniques

What functionality did Bruno Denuit of Microsoft help with?

Questions regarding window functions in SQL Server 2005.

p.22
Advanced SQL Techniques

Who kept the author updated about new SQL features in PostgreSQL?

Simon Riggs.

p.10
String Manipulation in SQL

How can unwanted characters be removed from a string in SQL?

By using string functions that filter or replace characters.

p.13
Advanced SQL Techniques

What SQL Server operator is used to create cross-tab reports?

PIVOT operator.

p.9
Metadata Queries

Why is it important to list foreign keys without corresponding indexes?

To identify potential performance issues and ensure referential integrity.

p.33
Retrieving Records

What is the purpose of using ORDER BY with a random function?

To sort rows randomly before limiting the number of rows returned.

p.16
Working with Multiple Tables

What types of fields are present in the EMP table?

Numeric, string, and date fields.

p.13
Numerical Operations in SQL

How can you calculate percent relative to total in SQL?

By using aggregate functions.

p.12
Advanced SQL Techniques

What does shifting row values entail?

Adjusting the position of data within a result set to compare current and previous values.

p.12
Advanced SQL Techniques

How can simple forecasts be generated in SQL?

By using historical data to predict future values through aggregation and trend analysis.

p.12
Working with Multiple Tables

What is the significance of hierarchical queries?

To retrieve data that has a parent-child relationship, allowing for structured data representation.

p.23
Advanced SQL Techniques

What is the purpose of the GENERATE_SERIES function?

To provide more elegant solutions compared to pivot tables.

p.23
Advanced SQL Techniques

What type of problems did Kay Young and the author work on together?

Everyday SQL problems at Wireless Generation.

p.23
Advanced SQL Techniques

What role did Kay Young play in the writing of the book?

Provided advice, grammar corrections, and code assistance.

p.26
Retrieving Records

How can you retrieve specific columns from a table?

By specifying the columns you are interested in the SELECT statement.

p.18
SQL Basics

How does the book differentiate SQL keywords in the text?

By using uppercase for SQL keywords and identifiers.

p.15
SQL Basics

What prior knowledge is suggested for readers of this book?

Some familiarity with SQL, such as having read 'Learning SQL' by Alan Beaulieu.

p.24
Retrieving Records

What does the * character represent in SQL?

It returns every column for the specified table.

p.28
Retrieving Records

What is the order of evaluation for SQL clauses?

FROM clause is evaluated before the WHERE clause, and SELECT clause is evaluated after.

p.34
Advanced SQL Techniques

How do you limit the number of rows returned in Oracle?

Use ROWNUM in the WHERE clause.

p.8
Retrieving Records

What is the focus of section 1.4?

Retrieving a Subset of Columns from a Table.

p.14
Advanced SQL Techniques

What significant change has occurred regarding CTEs since the first edition?

CTEs are now available in all five implementations of SQL.

p.22
Advanced SQL Techniques

Who is thanked for reviewing the MODEL clause article?

John Haydu and the MODEL clause development team at Oracle Corporation.

p.31
Retrieving Records

What is the SQL command to limit the number of rows to 5 in MySQL?

SELECT * FROM emp LIMIT 5.

p.9
Working with Multiple Tables

What is the method to retrieve values from one table that do not exist in another?

Using a LEFT JOIN with a NULL check or NOT EXISTS clause.

p.32
Retrieving Records

What do many SQL vendors provide to limit the number of rows returned?

Clauses such as FETCH FIRST and LIMIT.

p.11
Date and Time Functions

What is covered in section 9.1?

Determining Whether a Year Is a Leap Year.

p.13
String Manipulation in SQL

What is a method to extract elements of a string from unfixed locations?

Using string functions in SQL.

p.30
String Manipulation in SQL

How do you concatenate strings in SQL Server?

Using the + operator.

p.13
String Manipulation in SQL

What is the method for parsing serialized data into rows?

Using string manipulation functions.

p.12
Numerical Operations in SQL

How do you find records with the highest and lowest values?

By using the MAX() and MIN() functions in SQL queries.

p.12
Retrieving Records

What is the method for suppressing duplicates in SQL results?

Using the DISTINCT keyword to eliminate duplicate rows from the result set.

p.28
SQL Basics

What is the purpose of creating aliases in SQL queries?

To make the query and its results more understandable to others.

p.18
SQL Basics

What does constant width bold indicate in examples?

User input, tips, suggestions, or warnings.

p.14
SQL Basics

What is SQL often referred to as in the data profession?

The lingua franca of the data professional.

p.5
Metadata Queries

When was the first edition of the SQL Cookbook published?

December 2005.

p.34
Advanced SQL Techniques

How do you select 5 random employees in PostgreSQL?

Use the query: SELECT ename, job FROM emp ORDER BY random() LIMIT 5.

p.21
Advanced SQL Techniques

What did the author's in-laws provide during his writing experience?

Support and a feeling of being at home.

p.20
Metadata Queries

What email address can be used to ask technical questions about the book?

bookquestions@oreilly.com.

p.14
SQL Basics

What is a common misconception about SQL users?

That they only need to know the simplest queries.

p.15
SQL Basics

What versions of SQL platforms were used in the preparation of this text?

DB2 11.5, Oracle Database 19c, PostgreSQL 12.

p.20
Metadata Queries

What social media platforms can you follow O’Reilly Media on?

Facebook, Twitter, and YouTube.

p.24
Retrieving Records

What is a recommended practice when writing program code for SQL queries?

Specify each column individually instead of using SELECT *.

p.19
Advanced SQL Techniques

What is the purpose of numbering SQL in the 'Solution' section of recipes?

To reference parts of the query by number in the 'Discussion' section.

p.21
Advanced SQL Techniques

What does Ales Spetic hope for the book in relation to other SQL authors?

That it will complement the existing works of outstanding authors.

p.14
SQL Basics

Why is this book considered a 'second book on SQL'?

It is meant for readers who have learned the basics and want to expand their knowledge.

p.25
Retrieving Records

How can you specify multiple conditions in a SQL query?

By using AND, OR, and parentheses in the WHERE clause.

p.11
Date and Time Functions

What does section 9 focus on?

Date Manipulation.

p.33
Retrieving Records

Why does ROWNUM = 1 work to return the first row?

Oracle must attempt to fetch at least once to determine if there are any rows in the table.

p.10
Numerical Operations in SQL

What is the focus of section 7 in the document?

Working with Numbers.

p.30
Advanced SQL Techniques

What conditional logic can be used in a SELECT statement to categorize employee salaries?

IF-ELSE operations.

p.13
Advanced SQL Techniques

What is the difference between a scalar subquery and a composite subquery in Oracle?

A scalar subquery returns a single value, while a composite subquery can return multiple values.

p.12
Retrieving Records

How can you determine which rows are reciprocals in a dataset?

By comparing values in two columns to identify pairs that are inverses of each other.

p.12
Sorting Query Results

How can results be ranked in SQL?

Using the RANK() or DENSE_RANK() functions to assign a rank to each row based on specified criteria.

p.12
Reporting and Reshaping

How can you create buckets of data in SQL?

By using the GROUP BY clause to categorize data into defined ranges or intervals.

p.28
Working with Multiple Tables

What is the structure of the inline view used to reference aliases?

SELECT * FROM (SELECT sal AS salary, comm AS commission FROM emp) x WHERE salary < 5000.

p.24
Retrieving Records

What SQL command is used to retrieve all rows and columns from a table?

SELECT * FROM table_name;

p.29
Retrieving Records

What result set is produced by concatenating the ENAME and JOB columns?

CLARK WORKS AS A MANAGER, KING WORKS AS A PRESIDENT, MILLER WORKS AS A CLERK.

p.26
Retrieving Records

What would the query 'select * from emp where deptno = 10 or comm is not null or sal <= 2000 and deptno=20' return?

Rows where DEPTNO is 10, COMM is not NULL, or salary is $2,000 or less for DEPTNO 20.

p.19
Advanced SQL Techniques

What is the purpose of using aliases like X and Y in inline views?

To identify the result sets from inline views.

p.22
Advanced SQL Techniques

Who provided feedback on the window function refresher?

Maggie Ho.

p.15
SQL Basics

What is the emphasis of this book?

Practical queries that can solve real-world problems.

p.34
Advanced SQL Techniques

What does the ORDER BY clause do when used with a function?

It changes the order of the result set based on the function's return value.

p.11
Date and Time Functions

What is the focus of section 8 in the document?

Date Arithmetic.

p.14
Advanced SQL Techniques

What was the status of window functions at the time of the first edition?

They were not available in every implementation.

p.11
Date and Time Functions

What is discussed in section 8.2?

Determining the Number of Days Between Two Dates.

p.8
Sorting Query Results

What is the last section in the table of contents?

2.7 Summing Up.

p.9
Inserting, Updating, and Deleting Records

What is the purpose of merging records?

To combine data from multiple records into a single record based on certain criteria.

p.11
Advanced SQL Techniques

What is the main topic of section 11?

Advanced Searching.

p.30
String Manipulation in SQL

What function does MySQL use for concatenation?

CONCAT.

p.30
String Manipulation in SQL

What is the SQL syntax to concatenate employee name and job in MySQL?

SELECT CONCAT(ename, ' WORKS AS A ', job) AS msg FROM emp WHERE deptno=10.

p.13
Advanced SQL Techniques

How can you add a column header into a double pivoted result set?

By modifying the query structure.

p.16
Retrieving Records

What SQL command is used to display all records from the EMP table?

select * from emp;

p.12
Reporting and Reshaping

What is the purpose of pivoting a result set?

To transform rows into columns for better data representation and analysis.

p.22
Advanced SQL Techniques

What book by David Rozenshtein helped the author understand problem-solving in SQL?

Essence of SQL.

p.27
Retrieving Records

How would you write a query to rename 'sal' and 'comm' to 'salary' and 'commission'?

SELECT sal AS salary, comm AS commission FROM emp.

p.22
Advanced SQL Techniques

Which book did the author learn advanced SQL techniques from?

Optimizing Transact-SQL.

p.26
Retrieving Records

How would you write a query to see only the name, department number, and salary for employees?

select ename, deptno, sal from emp.

p.17
SQL Basics

What is a notable feature of some vendors regarding SELECT statements?

They allow partial SELECT statements without a FROM clause.

p.8
Retrieving Records

What does section 1.5 address?

Providing Meaningful Names for Columns.

p.21
Advanced SQL Techniques

Who does the author acknowledge as influential figures in the SQL community?

Joe Celko, David Rozenshtein, Anatoly Abramovich, Eugine Berger, Iztik Ben-Gan, Richard Snodgrass, and others.

p.8
Sorting Query Results

What is discussed in section 2.1?

Returning Query Results in a Specified Order.

p.8
Sorting Query Results

Which section deals with sorting by multiple fields?

2.2 Sorting by Multiple Fields.

p.10
String Manipulation in SQL

What is the significance of extracting initials from a name?

It allows for concise representation of names in data processing.

p.10
Numerical Operations in SQL

What SQL function can be used to find the minimum or maximum value in a column?

MIN() for minimum and MAX() for maximum.

p.30
Advanced SQL Techniques

Provide an example of a result set using conditional logic for employee salaries.

ENAME, SAL, STATUS: SMITH, 800, UNDERPAID; KING, 5000, OVERPAID.

p.16
Working with Multiple Tables

What is the purpose of using the EMP and DEPT tables in this book?

To provide examples that are likely to be implemented in the real world.

p.12
Advanced SQL Techniques

What is the purpose of investigating future rows in SQL?

To analyze upcoming data points based on current trends or historical data.

p.12
Date and Time Functions

How can you group rows by units of time in SQL?

By using the GROUP BY clause with date or time functions to aggregate data over specified time intervals.

p.9
Working with Multiple Tables

What is the purpose of stacking one rowset atop another?

To combine multiple sets of data into a single result set.

p.25
Retrieving Records

How can you retrieve only specific rows from a table?

By using the WHERE clause to specify conditions.

p.34
Retrieving Records

How can you find all rows that are null for a particular column?

Use a query with the WHERE clause to check for NULL values.

p.8
Sorting Query Results

What does section 2.5 focus on?

Dealing with Nulls When Sorting.

p.33
Retrieving Records

Why does ROWNUM = 5 fail to return the fifth row?

You can't have a fifth row if rows one through four haven't been returned first.

p.11
Advanced SQL Techniques

What does section 11.1 discuss?

Paginating Through a Result Set.

p.13
Date and Time Functions

How can you find the number of days in a year using Oracle?

By using date functions.

p.16
Working with Multiple Tables

What are the two main tables used in the examples of this book?

EMP and DEPT.

p.16
Working with Multiple Tables

What types of fields are present in the DEPT table?

Numeric and string fields.

p.12
Retrieving Records

What is the method for selecting the top n records in SQL?

Using the LIMIT clause or equivalent to restrict the number of returned rows.

p.12
Advanced SQL Techniques

What is a sparse matrix in SQL?

A matrix representation where most elements are zero or empty, often used for efficient storage.

p.24
Retrieving Records

What are the benefits of specifying each column in a SQL query?

It improves clarity and ensures you know what columns are being returned.

p.17
SQL Basics

Why are coding conventions important in this book?

They enhance understanding and cannot be repeated for each recipe.

p.25
Retrieving Records

What operators are commonly supported in the WHERE clause?

=, <, >, <=, >=, !, and <>.

p.10
String Manipulation in SQL

What is one method to count occurrences of a character in a string?

Using specific SQL functions designed for string manipulation.

p.33
Retrieving Records

What does Oracle call the first row fetched from a query?

Row number one.

p.10
String Manipulation in SQL

What is the purpose of separating numeric and character data?

To facilitate data analysis and ensure accurate calculations.

p.9
Metadata Queries

What is the function of listing tables in a schema?

To view all tables available within a specific database schema.

p.33
Retrieving Records

What is the problem when trying to return a specific number of random records from a table?

You want to produce a different set of rows with each execution.

p.10
Numerical Operations in SQL

How can you compute an average in SQL?

By using the AVG() function on a numeric column.

p.10
Numerical Operations in SQL

What is a running total in SQL?

A cumulative sum of values in a column over a specified range.

p.30
Advanced SQL Techniques

What message is returned for employees earning $4,000 or more?

OVERPAID.

p.13
Retrieving Records

What is a technique for testing the existence of a value within a group?

Using EXISTS or IN clauses.

p.12
Working with Multiple Tables

What is the purpose of incorporating OR logic when using outer joins?

To combine rows from two or more tables based on a related column, allowing for more flexible query results.

p.9
Working with Multiple Tables

What is the significance of using NULLs in operations and comparisons?

NULLs represent missing or unknown data, affecting query results and logic.

p.9
Inserting, Updating, and Deleting Records

How can you delete specific records from a table?

By using the DELETE statement with a WHERE clause to specify conditions.

p.13
Advanced SQL Techniques

What is the purpose of the UNPIVOT operator in SQL Server?

To unpivot a cross-tab report.

p.33
Retrieving Records

How can you return random records in DB2?

Use the RAND function in conjunction with ORDER BY and FETCH.

p.33
Retrieving Records

What SQL statement can be used in MySQL to return five random records?

SELECT ename, job FROM emp ORDER BY RAND() LIMIT 5.

p.30
String Manipulation in SQL

What is the shortcut for the CONCAT function in DB2, Oracle, and PostgreSQL?

The || operator.

p.16
Working with Multiple Tables

How many rows does the EMP table contain?

14 rows.

p.30
Advanced SQL Techniques

What message is returned for employees earning between $2,000 and $4,000?

OK.

Study Smarter, Not Harder
Study Smarter, Not Harder