ZahidKakar
ZahidKakar

Reputation: 212

Select a value based on From and To Range values

I have a Table in SQL Server 2012 Database called TblAccttAssistant. It has the below Data Values as shown in image:-TblAccttAssistant

I want to use Sql Query to Select a Single value based for PPO_From and PPO_To column values range:

      Select * from TblAccttAssistant  where (ppo_from >=2500 ANd ppo_to<=2500)

I have to provide a single value 2500 to query. It is getting 0 No of Rows.

Upvotes: 1

Views: 1048

Answers (2)

Ali K Al Azzeh
Ali K Al Azzeh

Reputation: 17

Select * from TblAccttAssistant  where (ppo_from <=2500 ANd ppo_to>=2500)

Upvotes: 0

RoundFour
RoundFour

Reputation: 347

You're probably looking for the BETWEEN operator?

SELECT * FROM TblAccttAssistant WHERE 2500 BETWEEN ppo_from AND ppo_to

Your query doesn't work because there is no row satisfying both of your WHERE-conditions.

Upvotes: 1

Related Questions