Global Sorting using ORDER BY

#1

Let us see how we can sort the data globally using ORDER BY.

  • When we sort the data using ORDER BY, only one reducer will be used for sorting.
  • We can sort the data either in ascending or descending order.
  • By default data will be sorted in ascending order.
  • We can sort the data using multiple columns.
  • If we have sort the data in descending order on a particular column, then we need to specify DESC on that column.

Let us see few examples of using ORDER BY to sort the data.

SELECT * FROM orders
ORDER BY order_customer_id
LIMIT 10;

SELECT * FROM orders
ORDER BY order_customer_id, order_date
LIMIT 10;

SELECT * FROM orders
ORDER BY order_customer_id ASC, order_date DESC
LIMIT 10;

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