Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions

Errata for Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions




The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed, PDF
Page 1
N/A

You can find the book's companion website here: http://tsql.solidq.com/books/windowfunctions2012/.

Itzik Ben-Gan
 
Jan 05, 2013 
Printed
Page 20
Second paragraph, Second sentence

Currently: "Another way to look at it is that inf case explicit partitioning wasn't specified, the default partitioning is to consider the entire result set of the query as one partition." Should be: "Another way to look at it is that in case explicit partitioning wasn't specified, the default partitioning is to consider the entire result set of the query as one partition."

Anonymous  Jun 07, 2012 
PDF
Page 70
1st script

WITH C AS ( SELECT testid, studentid, score, RANK() OVER(PARTITION BY testid ORDER BY score) AS rk, COUNT(*) OVER(PARTITION BY testid) AS nr FROM Stats.Scores ) SELECT testid, studentid, score, 1.0 * (rk - 1) / (nr - 1) AS percentrank, 1.0 * (SELECT COALESCE(MIN(C2.rk) - 1, C1.nr) FROM C AS C2 WHERE C2.rk > C1.rk) / nr AS cumedist FROM C AS C1; WHERE clause should be changed like following to check rk in same partition: WHERE C2.rk > C1.rk AND C2.testid = C1.testid

Note from the Author or Editor:
Nice catch! The query in page 70 should be changed to the following: WITH C AS ( SELECT testid, studentid, score, RANK() OVER(PARTITION BY testid ORDER BY score) AS rk, COUNT(*) OVER(PARTITION BY testid) AS nr FROM Stats.Scores ) SELECT testid, studentid, score, 1.0 * (rk - 1) / (nr - 1) AS percentrank, 1.0 * (SELECT COALESCE(MIN(C2.rk) - 1, C1.nr) FROM C AS C2 WHERE C2.testid = C1.testid AND C2.rk > C1.rk) / nr AS cumedist FROM C AS C1; Description of change: WHERE clause in subquery was revised from: WHERE C2.rk > C1.rk To: WHERE C2.testid = C1.testid AND C2.rk > C1.rk Thanks for reporting this! Cheers, Itzik

Anonymous  Aug 12, 2013 
Printed
Page 107
two sentences before query:

Currently: "So simply adding a presentation ORDER BY clause with tranid DESC to our last query removes the need for a Sort iterator. Here's the revised query:" Should be: "So simply adding a presentation ORDER BY clause with actid DESC to our last query removes the need for a Sort iterator. Here's the revised query:"

Anonymous  Jun 07, 2012