Saturday, 1 August 2020

Find the biggest number among all the 5 integer columns in a Hive table?

Find the biggest number among all the 5 integer fields in a Hive table?

// here we have a table with 5 integer columns named a to e.
hive> create table tblgreatest (a int, b int, c int, d int, e int);
OK

hive> insert into tblgreatest values 
(1,2,3,4,5), 
(10,5,3,2,1), 
(3,34,1,3,2), 
(22,10,2,55,22);

hive> select * from tblgreatest;
OK
1 2 3 4 5
10 5 3 2 1
3 34 1 3 2
22 10 2 55 22
Time taken: 0.235 seconds, Fetched: 4 row(s)

// greatest : is the function used to find the biggest number against the specified integer column names
hive> select greatest(a,b,c,d,e) from tblgreatest;
OK
5
10
34 
55

No comments:

Post a Comment

Flume - Simple Demo

// create a folder in hdfs : $ hdfs dfs -mkdir /user/flumeExa // Create a shell script which generates : Hadoop in real world <n>...