Check out example codes for "groupby sort sql hive". It will help you in understanding the concepts better.

Code Example 1

SELECT 
    place, 
    cnt, 
    sum_ 
FROM (
    SELECT 
        place, 
        count(*) as cnt, 
        sum(weight) as sum_ 
    FROM a 
    GROUP BY place
) a 
ORDER BY place;

Learn ReactJs, React Native from akashmittal.com