Anuj Tamrakar
Anuj Tamrakar

Reputation: 271

How do u use between operator for range?

This is my table Data

Id  Begin  End
1   0      1
2   1      3
3   3      4

This is my Query:

DECLARE @abc Float=1.5;
SELECT * FROM dbo.Slab  AS s WHERE @abc BETWEEN s.Begin  AND s.End

This give me 2 rows. I want to find a row for which @abc parameter is greater than Begin but less or equal to End.For example if @abc=1 i want to select 1 , if @abc=1.5 I want to select 2 , if @abc=3 i want to select 2 , if @abc=0.1 i want to select 1 and so on.

Upvotes: 3

Views: 53

Answers (1)

anjali
anjali

Reputation: 84

DECLARE @abc Float=1.5;
SELECT * FROM dbo.slab  AS s WHERE @abc > s.[begin] and @abc<=s.[end]

Upvotes: 1

Related Questions