T-SQL, indexing, execution plans, isolation and the tuning questions SQL Server shops ask.
Table sales(id, region, amount).
For every region that appears in the table, return how many sales it has
and the sum of their amounts. Columns: region, sale_count,
Table page_views(id, page, visitor). The same visitor can view the same
page many times, and visitor is NULL when the view came from an
anonymous session.
Table exam_results(id, student, subject, score). Every student
registered for a subject has a row; score is NULL when the student did
not actually sit the exam.
Table tickets(id, team, status, minutes_spent) where status is either
'open' or 'closed'.
Produce one row per team with three numbers side by side: how many
What is the difference between WHERE and HAVING? Can a query need
both at the same time?
Explain the difference between COUNT(*), COUNT(column) and
COUNT(DISTINCT column). Which of them can return a smaller number
than the others, and why?