Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Help in the query please

$
0
0

Hi, How I can use SELECT statement to avoid the data (1,2,3,4,5,6,7,8) in the result but I don't want to USE 'NOT IN' function. I want to use greater than and less than operator because data is huge. Please advise.

--Select * from #temp where cr>=1 and cr<9

Select * from #temp where cr not in (1,2,3,4,5,6,7,8) --How I can use > and < in this query/or any other query to avoid to write data in the (...).

create table #temp (cr int)

insert into @temp values (1)

insert into @temp values (2)

insert into @temp values (3)

insert into @temp values (4)

insert into @temp values (5)

insert into @temp values (6)

insert into @temp values (7)

insert into @temp values (8)

insert into @temp values (9)

insert into @temp values (10)

-Expected result

CR

---

9

10


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>