T-SQL reference
Short answers to the SQL Server questions people search for at work. Each one ends with a ticket you can try it on.
GETDATE()Today, yesterday, last week. And why “last 7 days” keeps including today.DATEADDMove a date backwards or forwards by any unit.DATEDIFFDays, months or years between two dates, and the boundary rule.ISNULLSwap NULL for a word or a zero. ISNULL or COALESCE?TOPThe first N rows. Meaningless without ORDER BY.Group by monthMonthly totals from daily rows, three ways.CASE WHENSmall, Medium, Large. If-then-else inside a query.LEFT JOIN … IS NULLCustomers who never ordered. Products that never sold.ROW_NUMBERLatest order per customer, the whole row.GROUP BY error 8120Msg 8120, explained and fixed.