Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL Subselects

I have two tables, one of which is a data table and the other an index table:

Data

TitleDescriptionCreated By
AlphaaaaaaaaaaaaaaaaaA1
BetabbbbbbbbbbbbbbbbbA2
GammaccccccccccccccccB1
DeltaddddddddddddddddA1
EpsiloneeeeeeeeeeeeeeeC1

Index

IDFirst Name
Last Name
Code
A1AlbertSmithABC123
A2JennyJonesDEF123
B1SamWilliamsXYZ999
B2KarlaTateHIJ000
C1JohnDoeLMN987

I want to load the Data table into Qlikview using the "Created By" field to link to the Index table so I can concatenate the "First Name" and "Last Name" fields based on a matching "Created By" value and "ID" value. I want the resulted concatenation stored in "User ID."

LOAD

    *,

    Concat(`Created By Last Name`,' ',`Created By First Name`) As `User ID`;

SQL SELECT

     Title,

     Description,

    (SELECT `Last name` FROM Index i WHERE i.ID=[d.Created By]) As `Created By Last Name`,

    (SELECT `First name` FROM Index i WHERE i.ID=[d.Created By]) As `Created By First Name`

FROM `Data` d;

This fails with an ODBC error (no descriptive text). What is missing?

1 Reply
flipside
Partner - Specialist II
Partner - Specialist II

Hi throwingmuse,

The Concat line is the error here as it doesn't work in the way it does in Excel. In Qlikview it will iterate over all values when used with a group by clause.  All you need to do for your requirement is combine using '&' ...

LOAD

    *,

    `Created By Last Name` & ' ' & `Created By First Name` As `User ID`;

flipside