# Brasil

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save \$300 before February 6: REGISTER NOW!
cancel
Showing results 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?

Labels (1)
• ### Qlik Sense

1 Solution

Accepted Solutions
Champion III

Try as below

MAIN:

Y

FROM

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

INNER JOIN(MAIN)

MIN(Z)

FROM

(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.
7 Replies
Champion III

Try as below

MAIN:

Y

FROM

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

INNER JOIN(MAIN)

MIN(Z)

FROM

(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.
Creator II

Boa tarde André, tudo bem?

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

TabelaFinal:

X,

Y

RESIDENT Tabela1;

INNER JOIN (TabelaFinal)

X,

Min(Z) AS Z

RESIDENT Tabela2

GROUP BY X;

DROP TABLES Tabela1, Tabela2;

Champion III

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]:

[Hora CRIA]

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

(ooxml, embedded labels, table is CRIACAO);

INNER JOIN

[ATEND]:

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

//[Hora ATEND]

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

(ooxml, embedded labels, table is ATEND);

[JUNTO]:

[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

Champion III

You are missing the Group By Clause !

[CREATION]:

[Time CRIA]

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

(ooxml, embedded labels, table is CRIACAO);

INNER JOIN

[ATEND]:

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

// [Hora attend]

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

(OOXML, embedded labels, the table is atend)

Group BY [Tel];

[TOGETHER]:

[Time CRIA]

[Hora attend]