Performing basic aggregations

#1

Let us see how we can use aggregate functions such as count, sum, min, max etc.

Here are few examples with respect to count.

SELECT count(1) FROM orders;
SELECT count(DISTINCT order_date) FROM orders;
SELECT count(DISTINCT order_date, order_status) 
FROM orders;

Let us see functions such as min, max, avg etc in action.

SELECT * FROM order_items WHERE order_item_order_id = 2;

SELECT sum(order_item_subtotal) 
FROM order_items 
WHERE order_item_order_id = 2;

SELECT sum(order_item_subtotal),
  min(order_item_subtotal),
  max(order_item_subtotal),
  avg(order_item_subtotal)
FROM order_items 
WHERE order_item_order_id = 2;

Practice hive on state of the art Big Data cluster - https://labs.itversity.com
You can sign up for our courses on Udemy using $10 coupons - Udemy Coupons - Big Data Courses


0 Likes