You are on page 1of 4

I am having an issue understanding how to link the following tables to give the

desired result(refer below). I don’t understand how I can link Team using another
field when there is no other shared unique field?

Tables:
Teams table:-

id = User team_id

Users table:-

Contracts table:-

Excel table:-

MasterCalendar table
Desired result:-

Team:
LOAD
//id as %TeamKey,
name as TeamName
;

SQL
SELECT * FROM team
;

User:
LOAD
team_id as %TeamKey,
id as %ConsultantKey,
FieldOfficer,
role
;

SQL Select
users.id,
users.team_id,
users.first_name ||' '|| users.surname as "FieldOfficer",
users.job_title,
users.archived,
users.role
from users
;

Facts:

LOAD
[Date Training Contract Signed] as %DateKey,
id as %ConsultantKey,
date([Created Date],'DD/MM/YYYY') as SUPDateOfCreation,
date([received_on],'DD/MM/YYYY') as SUPNTCReceivedDate,
signup_status_id as SUPStatus,
rtrim(ltrim([Account Manager])) as SUPAccountManager,
[BDL Referred By] as SUPBDLReferredBY,
bdl_referred_by_id,
at_fault,
1 as SUP#,
if(isnull([bdl_referred_by_id]), 0, 1) as SUPBDLLead#,
if([BDL Referred By]='Not BDL Lead',1,0) as SUPNotBDLLead#,
If(signup_status_id=5,1,0) as SUPComplete#,
If(signup_status_id=3,1,0) as SUPReceived#,
if(isnull(at_fault), 0, 1) as SUPReturn#,
if(at_fault,1,0) as AtFaultReturn#,
if(at_fault,0,1) as NotAtFaultReturn#
;

You might also like