Hive SQL支持多种数据计算,包括聚合函数、条件表达式、数学运算等。以下是一些常见的数据计算示例:
SELECT SUM(revenue) as total_revenue
FROM sales;
SELECT AVG(price) as average_price
FROM products;
SELECT product_id,
IF(price > 100, 'High', 'Low') as price_category
FROM products;
SELECT quantity * price as total_price
FROM sales;
SELECT CONCAT(first_name, ' ', last_name) as full_name
FROM users;
SELECT EXPLODE(split(interests, ',')) as interest
FROM users;
SELECT DATE_ADD('2021-01-01', 30) as date_30_days_later;
SELECT EXTRACT(YEAR FROM order_date) as order_year
FROM orders;
这些示例展示了Hive SQL中常见的数据计算操作。根据具体需求,还可以结合其他函数和操作符进行更复杂的数据计算。