Search code examples
hiveapache-pighiveql

Hive query or pig script to resolve the below mentioned issue


I have one table with below data:

A
B
C
D
E

output should like

AB
AC
AD
AE
BC
BD
BE
CD
CE
DE

How to do this in PIG and Hive


Solution

  • select  concat (t1.col, t2.col)
    from    t t1 cross join t t2
    where   t1.col < t2.col
    

    +----+
    | AB |
    | AC |
    | AD |
    | AE |
    | BC |
    | BD |
    | BE |
    | CD |
    | CE |
    | DE |
    +----+