Posted by : Anwar Hossain
Category : Basic sql tutorial for Beginner

SQL BETWEEN Operators for retrieving range values

Dear viewer I will show how to use SQL BETWEEN Operators. SQL BETWEEN Operator is used to select values within a range. Values can be text, date and numbers. On the other hand NOT Keywords can be used with SQL BETWEEN Operator .First I will find values using date value then money value text value and others example.

SQL BETWEEN examples in SQL server

Department Table

Department-table.png

Employee Table

EmployeeTable

SQL BETWEEN

SELECT column_name(s)

FROM table_name

WHERE column_name BETWEEN firstvalue AND secondvalue;

BETWEEN Operators for Money type values

SELECT * FROM Employee

WHERE Salary BETWEEN 30000 AND 50000;

SQL Statement Result

SQL-Between-operator-with-moneyType.png

BETWEEN Operators with Date range values

SELECT * FROM Employee

WHERE HireDate BETWEEN '12/01/2011'  AND '12/01/2012'

SQL Result

BETWEEN_-Operators_-with_-Date_-range_values.png

NOT BETWEEN Example with Numeric values

SELECT ELECT *

FROM Employee

WHERE Salary NOT BETWEEN 30000 AND 40000

SQL Statement Result

NOT_BETWEEN_Example_with_Numeric_values

NOT BETWEEN Examples with Date time values

SELECT *

FROM Employee

WHERE HireDate NOT  BETWEEN  '2011-01-11' AND '2012-01-12'

Out Put

NOT-_BETWEEN--Examples_with_-Date_-time_-values.png

BETWEEN Examples with IN Keyword

SELECT * FROM Employee

WHERE (Age BETWEEN 30 AND 35)

AND NOT DepId IN (1,3);

SQL Statement Result

BETWEEN-Examples-with-_IN-Keyword



Realted Article Headline

How to use MIN () Aggregate Function
How to use MAX () Aggregate Function
How to use SUM () aggregate function
how to use AVG () aggregate function
How to use sql alies for sql table
SQL BETWEEN Operators for retrieving range values
FULL OUTER JOIN using two tables in SQL server
LEFT JOIN using two tables in SQL server
How to join two table in sql server

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection