A cheat sheet on retrieving information 

The following table shows us how to retrieve information for some commonly used functions:

Function Hive
Retrieving Information (General) SELECT from_columns FROM table WHERE conditions;
Retrieving All Values SELECT * FROM table;
Retrieving Some Values  SELECT * FROM table WHERE rec_name = "value";
Retrieving With Multiple Criteria  SELECT * FROM TABLE WHERE rec1 = "value1" AND rec2 = "value2";
Retrieving Specific Columns  SELECT column_name FROM table;
Retrieving Unique Output  SELECT DISTINCT column_name FROM table;
Sorting  SELECT col1, col2 FROM table ORDER BY col2;
Sorting Reverse  SELECT col1, col2 FROM table ORDER BY col2 DESC;
Counting Rows  SELECT COUNT(*) FROM table;
Grouping With Counting  SELECT owner, COUNT(*) FROM table GROUP BY owner;
Maximum Value  SELECT MAX(col_name) AS label FROM table;
Selecting from multiple tables (Join same table using alias w/"AS" SELECT pet.name, comment FROM pet JOIN event ON (pet.name = event.name)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset