HiveQL in Hive (part 1)

Tram Ho

HiveQL series is already the last part in Hive series, maybe after I finish HiveQL, I will do a few more articles about Hive to answer some questions and frequently asked questions about Hive, some tutorials and resources. useful …. more. Let’s look forward to it!

1. Select-Where

Hive Query Language – Hive Query Language (HiveQL) – is a query language for Hive to conduct and analyze structured data in a Metastore. This section explains how to use a SELECT statement with a WHERE clause. The SELECT statement is often used to retrieve data from a table. The WHERE clause works similarly to a condition. It filters data using conditions and returns you a limited result. Built-in operators and functions create an expression that satisfies the condition.

Syntax

Given below is the syntax of the SELECT query:

Example

We will take an example of a SELECT … WHERE clause. Assume that we have employee table as below, together with fields: Id, Name, Salary, Designation, and Dept. Create a query to get details about employees who pay more than 3000Rs.

The following query retrieves the employee’s details using the following condition:

On successful execution of the query, you will receive the following response:

JDBC Program JDBC Program to apply where clause to the given example as follows:

Save the program in a file called HiveQLWhere.java. Use the following command to compile and execute the program:

Output:

. The next topic will be SELECT … ORDER BY.

Share the news now

Source : Viblo