■ CONTENTS
xiv
Joining a CTE to Another CTE ................................................................................. 347
Using the Alternate CTE Syntax.............................................................................. 349
Writing a Recursive Query ...................................................................................... 350
The OUTPUT Clause .................................................................................................... 352
Using OUTPUT to View Data.................................................................................... 353
Saving OUTPUT Data to a Table.............................................................................. 355
The MERGE Statement................................................................................................ 357
GROUPING SETS.......................................................................................................... 360
Pivoted Queries........................................................................................................... 361
Pivoting Data with CASE......................................................................................... 362
Using the PIVOT Function ....................................................................................... 363
TOP Enhancements..................................................................................................... 365
Ranking Functions ...................................................................................................... 367
Using ROW_NUMBER.............................................................................................. 368
Using RANK and DENSE_RANK............................................................................... 370
Using NTILE ............................................................................................................ 371
Database Cleanup....................................................................................................... 372
Summary .................................................................................................................... 373
■Chapter 11: Where to Go Next?......................................................................... 375
Online Resources........................................................................................................ 375
Conferences................................................................................................................ 376
User Groups ................................................................................................................ 376
Vendors....................................................................................................................... 377
Books.......................................................................................................................... 377
Classes ....................................................................................................................... 377
SQL Server Books Online............................................................................................ 377
Practice, Practice, and More Practice......................................................................... 378
Teach Someone Else................................................................................................... 378
■Appendix: Solutions to the Exercises ............................................................... 379
Chapter 2: Writing Simple SELECT Queries................................................................. 379
Solutions to Exercise 2-1: Using the SELECT Statement........................................ 379
Solutions to Exercise 2-2: Filtering Data ................................................................ 380
Solutions to Exercise 2-3: Filtering with Wildcards................................................ 381
Solutions to Exercise 2-4: Filtering with Multiple Predicates................................. 382