La cláusula Where de la instrucción Select nos permite filtrar los registros que se desean mostrar en base a una o mas condiciones, para especificar las condiciones se utilizan los operadores.Ejemplos: Siempre usando la base de datos Northwind.
1. Listar los productos de Categoría 3
Select * from Products Where CategoryId = 3
go
2. Listar los productos de las Categorías 4,6 y 7
Select * from Products Where CategoryId = 4 Or CategoryId = 6 Or CategoryId = 7
go
También se puede usar el operador In
Select * from Products Where CategoryId in (4,6,7)
go
3. Listar las órdenes de Setiembre 1996
Select * from Orders where OrderDate >=’01/09/1996′ and OrderDate < ’01/10/1996′
go
4. Listar los clientes cuyo nombre empieza con la letra B
Select * from Customers where CompanyName Like ‘B%’
go
5. Listar los clientes cuya Región no es Null
Select * from Customers where Region is Not Null
go
6. Listar los productos cuyos precios fluctúen entre 10 y 50, ordenados por Precio en orden descendente.
Select * from Products where UnitPrice between 10 and 50 order by UnitPrice desc
go
