Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Inner Join sem duplicação de registros

Considere a seguintes tabelas:

Tabela1:

XY
a1
b1
c1

Tabela2:

XZ
a1
a2
b1
d1

Ao combinar as tabelas utilizando Inner Join, temos:

XYZ
a11
a12
b11

Gostaria de estabelecer um critério para que 'a' não duplicasse. O critério seria o menor valor em Z para 'a'. Resultando na seguinte tabela:

XYZ
a11
b11

Como fazê-lo?

Desde já, agradeço as respostas.

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Try as below

MAIN:

LOAD X,

     Y

FROM

[https://community.qlik.com/thread/243397]

(html, codepage is 1252, embedded labels, table is @1);

INNER JOIN(MAIN)

LOAD X,

     MIN(Z)

FROM

[https://community.qlik.com/thread/243397]

(html, codepage is 1252, embedded labels, table is @2)

GROUP BY X;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

7 Replies
vinieme12
Champion III
Champion III

Try as below

MAIN:

LOAD X,

     Y

FROM

[https://community.qlik.com/thread/243397]

(html, codepage is 1252, embedded labels, table is @1);

INNER JOIN(MAIN)

LOAD X,

     MIN(Z)

FROM

[https://community.qlik.com/thread/243397]

(html, codepage is 1252, embedded labels, table is @2)

GROUP BY X;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
TiagoCardoso
Creator II
Creator II

Boa tarde André, tudo bem?

Tente o seguinte (fiz e cheguei no resultado que você descreveu):

TabelaFinal:

LOAD

  X,

  Y

RESIDENT Tabela1;

INNER JOIN (TabelaFinal)

LOAD

  X,

  Min(Z) AS Z

RESIDENT Tabela2

GROUP BY X;

DROP TABLES Tabela1, Tabela2;

vinieme12
Champion III
Champion III

if your Query is resolved please close the thread

Qlik Community Tip: Marking Replies as Correct or Helpful

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

Boa tarde, Tiago. Obrigado pela resposta!

Ao incluir a função Min(), recebo uma mensagem de erro:

Erro de script: Invalid expression

Ocorreram os seguintes erros:

Invalid expression

O erro ocorreu aqui:

INNER JOIN [ATEND]: LOAD [Tel], Min([Hora ATEND]) as [Hora ATEND] FROM [lib://Teste/Teste.xlsx] (ooxml, embedded labels, table is ATEND)

Meu script está dessa forma:

[CRIACAO]:

LOAD [Tel],

  [Hora CRIA]

FROM [lib://Teste/Teste.xlsx]

(ooxml, embedded labels, table is CRIACAO);

INNER JOIN

[ATEND]:

LOAD [Tel],

  Min([Hora ATEND]) as [Hora ATEND]

    //[Hora ATEND]

FROM [lib://Teste/Teste.xlsx]

(ooxml, embedded labels, table is ATEND);

[JUNTO]:

LOAD [Tel],

[Hora CRIA],

[Hora ATEND],

[Hora ATEND]-[Hora CRIA]

Resident CRIACAO;

DROP table CRIACAO;

Consegue me ajudar? O que pode estar ocorrendo?

Not applicable
Author

Se deixo o Min() de fora, não tenho problemas com a carga

vinieme12
Champion III
Champion III

You are missing the Group By Clause !

[CREATION]:

LOAD [Tel],

  [Time CRIA]

FROM [lib://Teste/Teste.xlsx]

(ooxml, embedded labels, table is CRIACAO);

INNER JOIN

[ATEND]:

LOAD [Tel],

  MIN ([Hora attend]) AS [Hora attend]

    // [Hora attend]

FROM [lib://Teste/Teste.xlsx]

(OOXML, embedded labels, the table is atend)

Group BY [Tel];

[TOGETHER]:

LOAD [Tel],

[Time CRIA]

[Hora attend]

[Time ANSWER] - [Time CRIA]

Resident CREATION;

DROP table CREATION;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Not applicable
Author

Thanks, Vineeth.