From the course: Analyzing Big Data with Hive

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filtering aggregates with HAVING clause

Filtering aggregates with HAVING clause - Hive Tutorial

From the course: Analyzing Big Data with Hive

Start my 1-month free trial

Filtering aggregates with HAVING clause

- [Instructor] Now let's take a look at Filtering Aggregates with the HAVING clause. The HAVING Clause, like the WHERE clause, allows you to focus your result set, this time however, that filtering is performed after you've done and aggregation, which is kind of a unique thing, and actually very common in lot of analysis work. First what we're going to do is build a simple aggregate query then filter those results using the HAVING clause. Here in my cloud environment I'm going to open up 5-2.sql, copy this, go over to my Hue editor, paste that in, and we can start here by creating a simple aggregate query. We have select, product category, sub category and key. And then a sum of sales amount from sales all years where the year equals 2009, remember that's our partition. Then we have to add our grouping, which is all the fields that are not a part of an aggregation, and we're goin to limit that to a thousand results, just in case there are millions of results, we just want the top…

Contents