Hive 是一个基于 Hadoop 的分布式数据仓库,它允许你使用类似于 SQL 的查询语言(HiveQL)来处理和分析大量数据
SELECT * FROM users WHERE age > 18;
SELECT * FROM users WHERE age BETWEEN 18 AND 30 AND name = 'John';
SELECT * FROM users WHERE name NOT LIKE 'John%';
SELECT * FROM users WHERE age BETWEEN 18 AND 30;
如果你想查询年龄不在 18 到 30 岁之间的用户,可以使用 NOT IN:
SELECT * FROM users WHERE age NOT IN (18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30);
SELECT * FROM users WHERE name LIKE 'John%';
SELECT * FROM users WHERE name REGEXP '^\\d+$';
SELECT user_id, AVG(amount) as avg_amount
FROM orders
GROUP BY user_id
HAVING AVG(amount) > 1000 AND MAX(age) BETWEEN 18 AND 30;
通过使用这些数据过滤技巧,你可以更有效地查询和分析 Hive 中的大量数据。