标签: sql sql-server tsql
现在,我使用BETWEEN条件来收集帐号,但我想要获取的唯一帐号是:
2999,3000至3004和3006 - 3010(基本上是跳过3005)
我如何格式化BETWEEN?
答案 0 :(得分:11)
您可以使用NOT IN从范围中排除值:
NOT IN
SELECT * FROM your_table WHERE col BETWEEN 2999 AND 3010 AND col NOT IN (3005) -- values you want to exclude