Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparing data from two different data sources

Hi all,

I'm trying to compare running times of benchmark tests which are stored in two different databases using charts. The data structure as well as the names of the fields are identical in each of the databases.

For example, I have the following tables containing the fields below:

TESTCASE
  TC_Id
  TC_Nr
  TC_Name
 
TESTCASE_RUN
  TCRun_Id
  TC_Id
  TC_Duration

I thought, the best thing for me would be to have the tables of each database in two different namespaces. So I used labels to declare namespaces. In the edit script I used the following code:

<code>
ODBC CONNECT32 TO [Database1] ...

QUALIFY *;
DB1:
SQL SELECT * FROM [Database1].TESTCASE

DB1:
SQL SELECT * FROM [Database1].TESTCASE_RUN

ODBC CONNECT32 TO [Database2] ...

DB2:
SQL SELECT * FROM [Database2].TESTCASE

DB2:
SQL SELECT * FROM [Database2].TESTCASE_RUN
</code>

This does not have the effect I want to achieve, since:

* On creating a new sheet object the following fields are shown:
  - DB1.TC_Id
  - DB1.TC_Nr
  - DB1.TC_Name
  - DB1-1.TCRun_Id
  - DB1-1.TC_Id
  - DB1-1.Duration
  - DB2.TC_Id
  - ...
* The tables of DB1 and DB1-1 are not connected, as they would be without using labels and the QUALIFY statement.

Does anybody has an idea how to import the tables from the different databases into different namespaces? I've also tried to rename the single fields in the script, didn't work either (Message: TC_Id already exists).

Thanks in advance!

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

because the fields in TESTCASE and TESTCASE_RUN are not the same, you cannot rely on auto-concatenation. This should solve your problem:

QUALIFY *;

DB1:

SQL SELECT * FROM [Database1].TESTCASE

Concatenate(DB1)

SQL SELECT * FROM [Database1].TESTCASE_RUN

Personally, I would not load the data into two separate namespaces, I would rather join them in a single table and use a field to indicate the source. Something like

CONNECT ... to DB1 ...

Data:

LOAD *,

          'DB1' As Source;

SQL SELECT * FROM [Database1].TESTCASE

 

Concatenate(Data)

LOAD *,

          'DB1' As Source;

SQL SELECT * FROM [Database1].TESTCASE_RUN

CONNECT ... to DB2 ...

Concatenate(Data)

LOAD *,

          'DB2' As Source;

SQL SELECT * FROM [Database1].TESTCASE

Concatenate(Data)

LOAD *,

          'DB2' As Source;

SQL SELECT * FROM [Database1].TESTCASE_RUN

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

because the fields in TESTCASE and TESTCASE_RUN are not the same, you cannot rely on auto-concatenation. This should solve your problem:

QUALIFY *;

DB1:

SQL SELECT * FROM [Database1].TESTCASE

Concatenate(DB1)

SQL SELECT * FROM [Database1].TESTCASE_RUN

Personally, I would not load the data into two separate namespaces, I would rather join them in a single table and use a field to indicate the source. Something like

CONNECT ... to DB1 ...

Data:

LOAD *,

          'DB1' As Source;

SQL SELECT * FROM [Database1].TESTCASE

 

Concatenate(Data)

LOAD *,

          'DB1' As Source;

SQL SELECT * FROM [Database1].TESTCASE_RUN

CONNECT ... to DB2 ...

Concatenate(Data)

LOAD *,

          'DB2' As Source;

SQL SELECT * FROM [Database1].TESTCASE

Concatenate(Data)

LOAD *,

          'DB2' As Source;

SQL SELECT * FROM [Database1].TESTCASE_RUN

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan,

thanks a lot for your quick response.

Your second suggestion is exactly what I need.

Cheers,

Johannes