Introduction to T-SQL

T-SQL is the language SQL Server speaks. You will ask your first questions of a database with SELECT, choose and calculate columns, sort and limit results, and filter rows with WHERE.

Updated

SELECT in T-SQL

  1. SELECT in T-SQL: an overview (Novice): A SELECT statement asks the database a question and gets back a table of answers; T-SQL is SQL Server's version of SQL.
  2. SELECT Query Structure (Novice): A SELECT statement is built from clauses that always appear in the same order; this chapter uses SELECT, FROM, WHERE and ORDER BY.
  3. Simple SELECT Query (Novice): SELECT * FROM a table returns every column and every row, the quickest way to see what a table holds.
  4. Specifying Columns (Novice): List the columns you want, in the order you want them, and rename them in the result with AS.
  5. Calculations in Columns (Apprentice): Work out new values as you query, with arithmetic on a row's columns and joined text, and give each calculated column a name.
  6. TOP and ORDER BY (Novice): Sort a query's results with ORDER BY, ascending or descending, by one column or several, and keep only the first rows with TOP.

WHERE in T-SQL

  1. WHERE in T-SQL: an overview (Novice): A WHERE clause keeps only the rows that match a condition, such as the customers in one country.
  2. Types of Filters (Apprentice): Filter numbers and dates with comparison operators, text with LIKE patterns, lists with IN, ranges with BETWEEN, and missing values with IS NULL.
  3. Using Multiple Condition Filters (Apprentice): Combine conditions in a WHERE clause with AND, OR and NOT, and use parentheses so they're checked the way you mean.