From the course: SQL Server 2014 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filtering results with a WHERE clause

Filtering results with a WHERE clause - SQL Server Tutorial

From the course: SQL Server 2014 Essential Training

Start my 1-month free trial

Filtering results with a WHERE clause

- Now we're going to look at filtering the results returned by a select query. Filtering those results, so that only the records that match a certain criteria are returned. Here in Management Studio, we'll start with a new query. We'll start with something pretty similar to what we worked with in the previous example. Where we're selecting four columns from HumanResources.Employee. And if we run this, we see in the lower right, the very lower right hand corner, it returned 290 rows. That is every row from the table. Now we're going to add a clause to this statement, to filter out certain rows. So being this record set is a list of employees, and how many vacation hours they have, a logical thing we might look at is how many people have more than a certain number of hours. So to do that, we'll add the keyword WHERE to the end of the SQL statement. Then we'll list the name of the column we would like to filter on, in this case, VacationHours. And then the values that we're looking for…

Contents