hive教程:between and查询范围

between…and

select * from 表名 where 列名 between 小值 and 大值

注意: 包含最大值和最小值

例子

查询工资在 800 - 3000 的数据

select * from emp where sal between 800 and 3000;

一般较少使用,因为会引发歧义:是否包含 800 和 300,所以多使用下面形式:

select * from emp where  800<=sal and sal<=3000;

not between…and

查询工资 不在 800 - 3000 的数据

select * from emp where sal not between 800 and 3000;

原文出处:/show_1IXlQOhc7c7.html