SQL Queries for Mere Mortals cover

SQL Queries for Mere Mortals

A Hands-On Guide to Data Manipulation in SQL

by John L. Viescas

4th Edition

Publisher: Addison-Wesley Professional PTG

(0 reviews)

Book Details

Print ISBN9780134858333
eText ISBN9780134858357
PublisherAddison-Wesley Professional PTG
Publishing Year2018
Edition4th Edition
LanguageEnglish
Pages960

SQL Queries for Mere Mortals, 4th Edition by John L. Viescas is a practical guide focused on relational database principles and query creation. Designed for database administrators, developers, students, and generic database users, this text provides a structured path for constructing queries and manipulating data effectively across relational systems.

The initial sections explain relational database concepts and strategies for designing sound table structures. From these structural foundations, the volume covers fundamental query operations, including SELECT statements, expressions, filtering records with the WHERE clause, and sorting results using ORDER BY. Readers further learn how to alter existing datasets through UPDATE, INSERT, and DELETE operations.

By emphasizing a software-independent approach, the text delivers generic SQL syntax that applies across multiple relational platforms without restricting instruction to a single vendor database product. This universal instruction enables learners to build portable querying skills suitable for academic coursework, database administration, and software development.

Table of Contents

  1. Chapter 1: What Is Relational?

    • Types of Databases
    • A Brief History of the Relational Model
    • In the Beginning . . .
    • Relational Database Systems
    • Anatomy of a Relational Database
    • Tables
    • Columns
    • Rows
    • Keys
    • Views
    • Relationships
    • What’s in It for You?
    • Where Do You Go from Here?
    • Summary
  2. Chapter 2: Ensuring Your Database Structure Is Sound

    • Why Is this Chapter Here?
    • Why Worry about Sound Structures?
    • Fine-Tuning Columns
    • What’s in a Name? (Part One)
    • Smoothing Out the Rough Edges
    • Resolving Multipart Columns
    • Resolving Multivalued Columns
    • Fine-Tuning Tables
    • What’s in a Name? (Part Two)
    • Ensuring a Sound Structure
    • Resolving Unnecessary Duplicate Columns
    • Identification Is the Key
    • Establishing Solid Relationships
    • Establishing a Deletion Rule
    • Setting the Type of Participation
    • Setting the Degree of Participation
    • Is That All?
    • Summary
  3. Chapter 3: A Concise History of SQL

    • The Origins of SQL
    • Early Vendor Implementations
    • “. . . And Then There Was a Standard”
    • Evolution of the ANSI/ISO Standard
    • Other SQL Standards
    • Commercial Implementations
    • What the Future Holds
    • Why Should You Learn SQL?
    • Which Version of SQL Does this Book Cover?
    • Summary
  4. Chapter 4: Creating a Simple Query

    • Introducing SELECT
    • The SELECT Statement
    • A Quick Aside: Data versus Information
    • Translating Your Request into SQL
    • Expanding the Field of Vision
    • Using a Shortcut to Request All Columns
    • Eliminating Duplicate Rows
    • Sorting Information
    • First Things First: Collating Sequences
    • Let’s Now Come to Order
    • Saving Your Work
    • Sample Statements
    • Summary
    • Problems for You to Solve
  5. Chapter 5: Getting More Than Simple Columns

    • What Is an Expression?
    • What Type of Data Are You Trying to Express?
    • Changing Data Types: The CAST Function
    • Specifying Explicit Values
    • Character String Literals
    • Numeric Literals
    • Datetime Literals
    • Types of Expressions
    • Concatenation
    • Mathematical Expressions
    • Date and Time Arithmetic
    • Using Expressions in a SELECT Clause
    • Working with a Concatenation Expression
    • Naming the Expression
    • Working with a Mathematical Expression
    • Working with a Date Expression
    • A Brief Digression: Value Expressions
    • That “Nothing” Value: Null
    • Introducing Null
    • The Problem with Nulls
    • Sample Statements
    • Summary
    • Problems for You to Solve
  6. Chapter 6: Filtering Your Data

    • Refining What You See Using WHERE
    • The WHERE Clause
    • Using a WHERE Clause
    • Defining Search Conditions
    • Comparison
    • Range
    • Set Membership
    • Pattern Match
    • Null
    • Excluding Rows with NOT
    • Using Multiple Conditions
    • Introducing AND and OR
    • Excluding Rows: Take Two
    • Order of Precedence
    • Checking for Overlapping Ranges
    • Nulls Revisited: A Cautionary Note
    • Expressing Conditions in Different Ways
    • Sample Statements
    • Summary
    • Problems for You to Solve
  7. Chapter 7: Thinking in Sets

    • What Is a Set, Anyway?
    • Operations on Sets
    • Intersection
    • Intersection in Set Theory
    • Intersection between Result Sets
    • Problems You Can Solve with an Intersection
    • Difference
    • Difference in Set Theory
    • Difference between Result Sets
    • Problems You Can Solve with Difference
    • Union
    • Union in Set Theory
    • Combining Result Sets Using a Union
    • Problems You Can Solve with Union
    • SQL Set Operations
    • Classic Set Operations versus SQL
    • Finding Common Values: INTERSECT
    • Finding Missing Values: EXCEPT (DIFFERENCE)
    • Combining Sets: UNION
    • Summary
  8. Chapter 8: INNER JOINs

    • What Is a JOIN?
    • The INNER JOIN
    • What’s “Legal” to JOIN?
    • Column References
    • Syntax
    • Check Those Relationships!
    • Uses for INNER JOINs
    • Find Related Rows
    • Find Matching Values
    • Sample Statements
    • Two Tables
    • More Than Two Tables
    • Looking for Matching Values
    • Summary
    • Problems for You to Solve
  9. Chapter 9: OUTER JOINs

    • What Is an OUTER JOIN?
    • The LEFT/RIGHT OUTER JOIN
    • Syntax
    • The FULL OUTER JOIN
    • FULL OUTER JOIN on Non-Key Values
    • UNION JOIN
    • Uses for OUTER JOINs
    • Find Missing Values
    • Find Partially Matched Information
    • Sample Statements
    • Summary
    • Problems for You to Solve
  10. Chapter 10: UNIONs

    • What Is a UNION?
    • Writing Requests with UNION
    • Using Simple SELECT Statements
    • Combining Complex SELECT Statements
    • Using UNION More Than Once
    • Sorting a UNION
    • Uses for UNION
    • Sample Statements
    • Summary
    • Problems for You to Solve
  11. Chapter 11: Subqueries

    • What Is a Subquery?
    • Row Subqueries
    • Table Subqueries
    • Scalar Subqueries
    • Subqueries as Column Expressions
    • Syntax
    • An Introduction to Aggregate Functions: COUNT and MAX
    • Subqueries as Filters
    • Special Predicate Keywords for Subqueries
    • Uses for Subqueries
    • Build Subqueries as Column Expressions
    • Use Subqueries as Filters
    • Sample Statements
    • Subqueries in Expressions
    • Subqueries in Filters
    • Summary
    • Problems for You to Solve
  12. Chapter 12: Simple Totals

    • Aggregate Functions
    • Counting Rows and Values with COUNT
    • Computing a Total with SUM
    • Calculating a Mean Value with AVG
    • Finding the Largest Value with MAX
    • Finding the Smallest Value with MIN
    • Using More Than One Function
    • Using Aggregate Functions in Filters
    • Sample Statements
    • Summary
    • Problems for You to Solve
  13. Chapter 13: Grouping Data

    • Why Group Data?
    • The GROUP BY Clause
    • Syntax
    • Mixing Columns and Expressions
    • Using GROUP BY in a Subquery in a WHERE Clause
    • Simulating a SELECT DISTINCT Statement
    • “Some Restrictions Apply”
    • Column Restrictions
    • Grouping on Expressions
    • Uses for GROUP BY
    • Sample Statements
    • Summary
    • Problems for You to Solve
  14. Chapter 14: Filtering Grouped Data

    • A New Meaning for “Focus Groups”
    • Where You Filter Makes a Difference
    • Should You Filter in WHERE or in HAVING?
    • Avoiding the HAVING COUNT Trap
    • Uses for HAVING
    • Sample Statements
    • Summary
    • Problems for You to Solve
  15. Chapter 15: Updating Sets of Data

    • What Is an UPDATE?
    • The UPDATE Statement
    • Using a Simple UPDATE Expression
    • A Brief Aside: Transactions
    • Updating Multiple Columns
    • Using a Subquery to Filter Rows
    • Some Database Systems Allow a JOIN in the UPDATE Clause
    • Using a Subquery UPDATE Expression
    • Uses for UPDATE
    • Sample Statements
    • Summary
    • Problems for You to Solve
  16. Chapter 16: Inserting Sets of Data

    • What Is an INSERT?
    • The INSERT Statement
    • Inserting Values
    • Generating the Next Primary Key Value
    • Inserting Data by Using SELECT
    • Uses for INSERT
    • Sample Statements
    • Summary
    • Problems for You to Solve
  17. Chapter 17: Deleting Sets of Data

    • What Is a DELETE?
    • The DELETE Statement
    • Deleting All Rows
    • Deleting Some Rows
    • Uses for DELETE
    • Sample Statements
    • Summary
    • Problems for You to Solve
  18. Chapter 18: “NOT” and “AND” Problems

    • A Short Review of Sets
    • Sets with Multiple AND Criteria
    • Sets with Multiple NOT Criteria
    • Sets Including Some Criteria but Excluding Others
    • Finding Out the “Not” Case
    • Using OUTER JOIN
    • Using NOT IN
    • Using NOT EXISTS
    • Using GROUP BY/HAVING
    • Finding Multiple Matches in the Same Table
    • Using INNER JOIN
    • Using IN
    • Using EXISTS
    • Sample Statements
    • Summary
    • Problems for You to Solve
  19. Chapter 19: Condition Testing

    • Conditional Expressions (CASE)
    • Why Use CASE?
    • Syntax
    • Solving Problems with CASE
    • Solving Problems with Simple CASE
    • Solving Problems with Searched CASE
    • Using CASE in a WHERE Clause
    • Sample Statements
    • Summary
    • Problems for You to Solve
  20. Chapter 20: Using Unlinked Data and “Driver” Tables

    • What Is Unlinked Data?
    • Deciding When to Use a CROSS JOIN
    • Solving Problems with Unlinked Data
    • Solving Problems Using “Driver” Tables
    • Setting Up a Driver Table
    • Using a Driver Table
    • Sample Statements
    • Examples Using Unlinked Tables
    • Examples Using Driver Tables
    • Summary
    • Problems for You to Solve
  21. Chapter 21: Performing Complex Calculations on Groups

    • Grouping in Sub-Groups
    • Extending the GROUP BY Clause
    • Syntax
    • Getting Totals in a Hierarchy Using Rollup
    • Calculating Totals on Combinations Using CUBE
    • Creating a Union of Totals with GROUPING SETS
    • Variations on Grouping Techniques
    • Sample Statements
    • Examples using ROLLUP
    • Examples using CUBE
    • Examples using GROUPING SETS
    • Summary
    • Problems for You to Solve
  22. Chapter 22: Partitioning Data into Windows

    • What You Can Do With a “Window” into Your Data
    • Syntax
    • Calculating a Row Number
    • Ranking Data
    • Splitting Data into Quintiles
    • Using Windows with Aggregate Functions
    • Sample Statements
    • Examples Using ROW_NUMBER
    • Examples Using RANK, DENSE_RANK, and PERCENT_RANK
    • Examples Using NTILE
    • Examples Using Aggregate Functions
    • Summary
    • Problems for You to Solve
  23. Chapter Appendix A: SQL Standard Diagrams

  24. Chapter Appendix B: Schema for the Sample Databases

    • Sales Orders Example Database
    • Sales Orders Modify Database
    • Entertainment Agency Example Database
    • Entertainment Agency Modify Database
    • School Scheduling Example Database
    • School Scheduling Modify Database
    • Bowling League Example Database
    • Bowling League Modify Database
    • Recipes Database
    • “Driver” Tables
  25. Chapter Appendix C: Date and Time Types, Operations, and Functions

    • IBM DB2
    • Microsoft Access
    • Microsoft SQL Server
    • MySQL
    • Oracle
    • PostgreSQL
  26. Chapter Appendix D: Suggested Reading

    • Database Books
    • Books on SQL

Customer Reviews

0.0

0 reviews

5 stars
0
4 stars
0
3 stars
0
2 stars
0
1 stars
0

No reviews yet. Be the first to review this book!

Write a Review

Select rating

0/20 characters minimum

By submitting a review, you agree that it may be published after moderation.

Research Sources (12)

Related Books