sqlhive

Adding another groupby in Hive


I have applied the group by function to sum a category in Hive. I am currently selecting by individual year from the database (where year = "2015").

How do I apply another group by so that the information is outputted for each year in the database?

select year, product,
    sum(sales)
from database
where year = "2015"
group by year, product
order by product asc;

Solution

  • You already have done group by year and product, if you need to select each year instead of only 2015 you can delete where year = "2015" and it will work