70-461 – sketchnote from chapter 1

I’m reading Querying Microsoft SQL Server 2012 by By Dejan Sarka, Itzik Ben-Gan, Ron Talmage and I thought it would be good to post something for each chapter.

My first offering is a sketchnote of the order in which a query is performed.
The example from the book is

SELECT country, YEAR(hiredate) AS yearhired, COUNT() AS numemployees
FROM HR.Employees
WHERE hiredate >= '20030101'
GROUP BY country, YEAR(hiredate)
) > 1
ORDER BY country, yearhired DESC;

In principle, the order is:

  1. from
  2. where
  3. group by
  4. having
  5. select
  6. order by



(Better version to be uploaded soon, I hope)

‘Order by’ and the Sorting Hat

In the course of doing the sketch, I thought about drawing Harry Potter’s Sorting Hat for the ‘order by’….but they aren’t all sorted into a specific order, so I didn’t.

On reflection, though the Sorting Hat would have been fine, it’s just that the ‘order by’ is

ORDER BY house


ORDER BY house, surname, forename

…but you’d still do it with an order by. How the Hat determines which house for which student is, of course, a more complicated question.