Day 2. Filtering and Sorting Data

In yesterday's lesson, you learned a little about what SQL is and how it relates to the SQL Server database. In addition, you were introduced to the Query Analyzer and some of its features. Using the Query Analyzer, you executed your first SQL query, returning all the data in the Employees table of the Northwind database.

Today, you will learn how to limit the number of rows you get back, and to sort those rows in a particular order, based on one or more columns returned in the query. These actions are the backbone of almost every SQL query that you will run. In fact, you can see an example of this at home in your bank statement. Each month you get a report (statement) that shows only the last month's data (filtering) and it is listed in date order (sorting).

Today, you will learn how the WHERE and ORDER BY clauses that can be used in the SELECT statement. You will cover the following topics along the way:

  • How and when to use the equality and inequality conditions in the WHERE clause

  • Using Boolean logic in the WHERE clause

  • Comparing a list of values with IN and NOT IN

  • Searching a range with BETWEEN and NOT BETWEEN

  • How to compare dates in SQL

  • What Null values are and how to use them

  • How to order or sort the data when it is returned

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset