Monday 8 August 2022

HIVE: Select specific columns

Syntax

select column1, column2…column from {table_name} where {condition}

 

hive> select * from employee;
OK
1   Hari    ["Football","Cricket"]  {"Java":"3.4Yrs","C":"4.5Yrs"}  {"gender":"Male","age":30}
2   Chamu   ["Trekking","Watching movies"]  {"Selenium":"5.6Yrs"}   {"gender":"Feale","age":38}
3   Sailu   ["Chess","Listening to music"]  {"EmbeddedC":"9Yrs"}    {"gender":"Femle","age":32}
4   Gopi    ["Cricket"] {"Datastage":"11Yrs"}   {"gender":"Male","age":32}
Time taken: 0.072 seconds, Fetched: 4 row(s)

 

a. Select name and gender of all the employees

hive> select name, gender_age.gender from employee;
OK
Hari    Male
Chamu   Feale
Sailu   Femle
Gopi    Male
Time taken: 0.079 seconds, Fetched: 4 row(s)

 

b. Select name, gender, age of employees whose age is > 30.

hive> select name, gender_age.gender, gender_age.age from employee where gender_age.age>30;
OK
Chamu   Feale   38
Sailu   Femle   32
Gopi    Male    32
Time taken: 0.09 seconds, Fetched: 3 row(s)

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment