Filtering post aggregation using HAVING


Let us see how we can filter the data based on aggregated results using HAVING Clause.

  • Having clause can be used only with GROUP BY
  • We need to use function as part of HAVING clause to filter the data based on aggregated results.
SELECT order_item_order_id,
  sum(order_item_subtotal) AS order_revenue
FROM order_items
GROUP BY order_item_order_id
HAVING sum(order_item_subtotal) >= 500;

Practice hive on state of the art Big Data cluster -
You can sign up for our courses on Udemy using $10 coupons - Udemy Coupons - Big Data Courses