Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
hamzabob1
Partner - Contributor III
Partner - Contributor III

how to display only differenet value from to table...

hello everyone,

i have one simple question can u help me out.

suppose i have two table as shown in below:

tableA:

LOAD * INLINE [

    name, value

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6

];

tableB:

LOAD * INLINE [

    name, value

    c, 3

    d, 4

    e, 5

];

now i want to display only uncommon name and vale.

Expected output:

name  value

a             1

b             2

f              6

thanks in advance.

1 Solution

Accepted Solutions
ramoncova06
Partner - Specialist III
Partner - Specialist III

do you want to do this at script or front end ? do you still want to keep both tables ?

here is a quick way of doing this, though will only keep table A with the non found values

mapping

tableB:

LOAD * INLINE [

    name, value

    c, 3

    d, 4

    e, 5

];

tableA:

Load

name,

value

where applymap('tableB', name,0) = 0

LOAD * INLINE [

    name, value

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6

];

View solution in original post

5 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

do you want to do this at script or front end ? do you still want to keep both tables ?

here is a quick way of doing this, though will only keep table A with the non found values

mapping

tableB:

LOAD * INLINE [

    name, value

    c, 3

    d, 4

    e, 5

];

tableA:

Load

name,

value

where applymap('tableB', name,0) = 0

LOAD * INLINE [

    name, value

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6

];

ramoncova06
Partner - Specialist III
Partner - Specialist III

here using the exists function, I change the name label on tableB


tableA:

LOAD * INLINE [

    name, value

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6];

tableB:

LOAD * INLINE [

    name1, value

    c, 3

    d, 4

    e, 5];

noconcatenate

tableC:

load

name,

value

resident  tableA

where not exists (name1, name);

maximiliano_vel
Partner - Creator III
Partner - Creator III

tableB:

LOAD * INLINE [

    name1, value1

    c, 3

    d, 4

    e, 5

];

tableA:

LOAD * INLINE [

    name2, value2

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6

]

WHERE Not Exists(name1, name2);

DROP Table tableB;

maxgro
MVP
MVP


I added some records in tableB and checked on name and value



1.png


tableA:

LOAD *, 1 as fromA INLINE [

    name, value

    a, 1

    b, 2

    c, 3

    d, 4

    e, 5

    f, 6

];

//tableB:

join (tableA)

LOAD *, 1 as fromB INLINE [

    name, value

    c, 3

    d, 4

    e, 5

  x, 20

  y, 21

  z, 22

];

left join (tableA)

LOAD

  name, value,

  if(rangesum(fromA,fromB)=1, 1) as uncommon

Resident tableA;

hamzabob1
Partner - Contributor III
Partner - Contributor III
Author

thanks everyone its working fine...

thanks again