I have 2 Data Tables coming from different sources syncing
into the same workspace. I have several
columns (Columns A – G) from Data Table 1 and 1 Column from Data Table 2 (Column
B) that I want to show up in a Query table.
DT 1 and DT 2 are joined by a common column (Column J in DT1
and Column A in DT 2).
SELECT
t1."JC_STD_ALT_GL" AS `Store Code`,
t1."Initials" AS `BDM`,
t1."JC_PROJ_MANAGER" AS `PM`,
t1."JC_DATE" AS `Booking Date`,
t1."Customer_Number",
t1."JC_CUSTOMER_NAME" AS `Customer Name`,
t1."JC_JI_LINE1" AS `Job Name`,
t1."JC_APPROVED_AMT" AS `Net Contract`,
t1."Orig Total Budget",
t1."GM$",
t1."GM%",
t1.`Base Job #`,
t1."Store Name",
t2."New or Existing"
CASE
WHEN t2."New or Existing"='Existing' THEN t1."GM$"*.035
WHEN t2."New or Existing"='New' THEN t1."GM$"*.14
END AS `BDM Commission`
FROM
"Bookings Detail tbl" AS t1
JOIN
"Accounts" AS t2
ON
t1."Customer_Number" = t2."Structure Account Number";