Hi all,
New user here struggling with table joining! Novice with SQL and appologize if I've used the wrong terminology.
Using: CR XI & SQL Server 2000
Trying to Link two tables in CR on multiple corresponding fields (the combination of all fields creates unique condition for join). When field values are Null, no records are returned ...how do I get them?
Below is the portion of the SQL Query from CR that I'm trying to work with:
LEFT OUTER JOIN "abecas_cs"."dbo"."PRCOMMITAC" "PRCOMMITAC" ON (((((((("ACACCOUNTING"."COMPANYID"="PRCOMMITAC"."COMPANYID") AND ("ACACCOUNTING"."P_GLACCOUNT"="PRCOMMITAC"."P_GLACCOUNT")) AND ("ACACCOUNTING"."P_BATCH"="PRCOMMITAC"."P_BATCH")) AND ("ACACCOUNTING"."P_GLDEPARTMENT"="PRCOMMITAC"."P_GLDEPARTMENT")) AND ("ACACCOUNTING"."FISCALYEAR"="PRCOMMITAC"."FISCALYEAR")) AND ("ACACCOUNTING"."FISCALPERIOD"="PRCOMMITAC"."FISCALPERIOD")) AND ("ACACCOUNTING"."P_GLFUND"="PRCOMMITAC"."P_GLFUND")) AND ("ACACCOUNTING"."P_CAJOB"="PRCOMMITAC"."P_CAJOB")) AND ("ACACCOUNTING"."P_CAACTIVITY"="PRCOMMITAC"."P_CAACTIVITY"))
CompanyID, P_Batch, P_GLAccount, FiscalYear, FiscalPeriod are always populated (FiscalPeriod can = 0).
P_GLDepartment, P_GLFund, P_CAJob, & P_CAActivity may or may not be Null and in most cases atleast one of them is Null.
P_{Fields} are pointer fields containing Keysequence record numbers.
Below is entire CR SQL Query so far:
SELECT "ACACCOUNTING"."GLACCRUALAMOUNT", "PRCOMMITAC"."GLACCRUALAMOUNT", "ACBATCH"."KEYSEQUENCE", "ACBATCH"."DESCRIPTION", "ACACCOUNTING"."SOURCE", "ACACCOUNT"."ACCOUNT", "ACACCOUNTING"."FISCALYEAR", "ACACCOUNTING"."FISCALPERIOD", "ACACCOUNTING"."COMPANYID", "PRCOMMITAC"."P_GLACCOUNT", "ACACCOUNTING"."P_GLACCOUNT", "ACACCOUNT"."DESCRIPTION", "IDMASTER_1"."IDENTITYID", (CASE
WHEN "ACACCOUNTING"."SOURCE"<>'PR' THEN
CASE
WHEN "ACACCOUNTING"."GLACCRUALAMOUNT">0 THEN "ACACCOUNTING"."GLACCRUALAMOUNT"
END
WHEN "ACACCOUNTING"."SOURCE"='PR' THEN
CASE
WHEN "PRCOMMITAC"."GLACCRUALAMOUNT">0 THEN "PRCOMMITAC"."GLACCRUALAMOUNT"
END
END), (CASE
WHEN "ACACCOUNTING"."SOURCE"<>'PR' THEN
CASE
WHEN "ACACCOUNTING"."GLACCRUALAMOUNT"<0 THEN "ACACCOUNTING"."GLACCRUALAMOUNT"*-1
END
WHEN "ACACCOUNTING"."SOURCE"='PR' THEN
CASE
WHEN "PRCOMMITAC"."GLACCRUALAMOUNT"<0 THEN "PRCOMMITAC"."GLACCRUALAMOUNT"*-1
END
END)
FROM ((("abecas_cs"."dbo"."ACACCOUNTING" "ACACCOUNTING" INNER JOIN "abecas_cs"."dbo"."ACACCOUNT" "ACACCOUNT" ON "ACACCOUNTING"."P_GLACCOUNT"="ACACCOUNT"."KEYSEQUENCE") INNER JOIN "abecas_cs"."dbo"."ACBATCH" "ACBATCH" ON "ACACCOUNTING"."P_BATCH"="ACBATCH"."KEYSEQUENCE") LEFT OUTER JOIN "abecas_cs"."dbo"."PRCOMMITAC" "PRCOMMITAC" ON (((((((("ACACCOUNTING"."COMPANYID"="PRCOMMITAC"."COMPANYID") AND ("ACACCOUNTING"."P_GLACCOUNT"="PRCOMMITAC"."P_GLACCOUNT")) AND ("ACACCOUNTING"."P_BATCH"="PRCOMMITAC"."P_BATCH")) AND ("ACACCOUNTING"."P_GLDEPARTMENT"="PRCOMMITAC"."P_GLDEPARTMENT")) AND ("ACACCOUNTING"."FISCALYEAR"="PRCOMMITAC"."FISCALYEAR")) AND ("ACACCOUNTING"."FISCALPERIOD"="PRCOMMITAC"."FISCALPERIOD")) AND ("ACACCOUNTING"."P_GLFUND"="PRCOMMITAC"."P_GLFUND")) AND ("ACACCOUNTING"."P_CAJOB"="PRCOMMITAC"."P_CAJOB")) AND ("ACACCOUNTING"."P_CAACTIVITY"="PRCOMMITAC"."P_CAACTIVITY")) INNER JOIN "abecas_cs"."dbo"."IDMASTER" "IDMASTER_1" ON "PRCOMMITAC"."P_IDENTITY"="IDMASTER_1"."KEYSEQUENCE"
WHERE "ACACCOUNTING"."COMPANYID"='D2' AND "ACACCOUNTING"."FISCALYEAR"=2005
ORDER BY "ACACCOUNT"."ACCOUNT", "ACACCOUNTING"."FISCALYEAR", "ACACCOUNTING"."FISCALPERIOD", "ACBATCH"."KEYSEQUENCE
New user here struggling with table joining! Novice with SQL and appologize if I've used the wrong terminology.
Using: CR XI & SQL Server 2000
Trying to Link two tables in CR on multiple corresponding fields (the combination of all fields creates unique condition for join). When field values are Null, no records are returned ...how do I get them?
Below is the portion of the SQL Query from CR that I'm trying to work with:
LEFT OUTER JOIN "abecas_cs"."dbo"."PRCOMMITAC" "PRCOMMITAC" ON (((((((("ACACCOUNTING"."COMPANYID"="PRCOMMITAC"."COMPANYID") AND ("ACACCOUNTING"."P_GLACCOUNT"="PRCOMMITAC"."P_GLACCOUNT")) AND ("ACACCOUNTING"."P_BATCH"="PRCOMMITAC"."P_BATCH")) AND ("ACACCOUNTING"."P_GLDEPARTMENT"="PRCOMMITAC"."P_GLDEPARTMENT")) AND ("ACACCOUNTING"."FISCALYEAR"="PRCOMMITAC"."FISCALYEAR")) AND ("ACACCOUNTING"."FISCALPERIOD"="PRCOMMITAC"."FISCALPERIOD")) AND ("ACACCOUNTING"."P_GLFUND"="PRCOMMITAC"."P_GLFUND")) AND ("ACACCOUNTING"."P_CAJOB"="PRCOMMITAC"."P_CAJOB")) AND ("ACACCOUNTING"."P_CAACTIVITY"="PRCOMMITAC"."P_CAACTIVITY"))
CompanyID, P_Batch, P_GLAccount, FiscalYear, FiscalPeriod are always populated (FiscalPeriod can = 0).
P_GLDepartment, P_GLFund, P_CAJob, & P_CAActivity may or may not be Null and in most cases atleast one of them is Null.
P_{Fields} are pointer fields containing Keysequence record numbers.
Below is entire CR SQL Query so far:
SELECT "ACACCOUNTING"."GLACCRUALAMOUNT", "PRCOMMITAC"."GLACCRUALAMOUNT", "ACBATCH"."KEYSEQUENCE", "ACBATCH"."DESCRIPTION", "ACACCOUNTING"."SOURCE", "ACACCOUNT"."ACCOUNT", "ACACCOUNTING"."FISCALYEAR", "ACACCOUNTING"."FISCALPERIOD", "ACACCOUNTING"."COMPANYID", "PRCOMMITAC"."P_GLACCOUNT", "ACACCOUNTING"."P_GLACCOUNT", "ACACCOUNT"."DESCRIPTION", "IDMASTER_1"."IDENTITYID", (CASE
WHEN "ACACCOUNTING"."SOURCE"<>'PR' THEN
CASE
WHEN "ACACCOUNTING"."GLACCRUALAMOUNT">0 THEN "ACACCOUNTING"."GLACCRUALAMOUNT"
END
WHEN "ACACCOUNTING"."SOURCE"='PR' THEN
CASE
WHEN "PRCOMMITAC"."GLACCRUALAMOUNT">0 THEN "PRCOMMITAC"."GLACCRUALAMOUNT"
END
END), (CASE
WHEN "ACACCOUNTING"."SOURCE"<>'PR' THEN
CASE
WHEN "ACACCOUNTING"."GLACCRUALAMOUNT"<0 THEN "ACACCOUNTING"."GLACCRUALAMOUNT"*-1
END
WHEN "ACACCOUNTING"."SOURCE"='PR' THEN
CASE
WHEN "PRCOMMITAC"."GLACCRUALAMOUNT"<0 THEN "PRCOMMITAC"."GLACCRUALAMOUNT"*-1
END
END)
FROM ((("abecas_cs"."dbo"."ACACCOUNTING" "ACACCOUNTING" INNER JOIN "abecas_cs"."dbo"."ACACCOUNT" "ACACCOUNT" ON "ACACCOUNTING"."P_GLACCOUNT"="ACACCOUNT"."KEYSEQUENCE") INNER JOIN "abecas_cs"."dbo"."ACBATCH" "ACBATCH" ON "ACACCOUNTING"."P_BATCH"="ACBATCH"."KEYSEQUENCE") LEFT OUTER JOIN "abecas_cs"."dbo"."PRCOMMITAC" "PRCOMMITAC" ON (((((((("ACACCOUNTING"."COMPANYID"="PRCOMMITAC"."COMPANYID") AND ("ACACCOUNTING"."P_GLACCOUNT"="PRCOMMITAC"."P_GLACCOUNT")) AND ("ACACCOUNTING"."P_BATCH"="PRCOMMITAC"."P_BATCH")) AND ("ACACCOUNTING"."P_GLDEPARTMENT"="PRCOMMITAC"."P_GLDEPARTMENT")) AND ("ACACCOUNTING"."FISCALYEAR"="PRCOMMITAC"."FISCALYEAR")) AND ("ACACCOUNTING"."FISCALPERIOD"="PRCOMMITAC"."FISCALPERIOD")) AND ("ACACCOUNTING"."P_GLFUND"="PRCOMMITAC"."P_GLFUND")) AND ("ACACCOUNTING"."P_CAJOB"="PRCOMMITAC"."P_CAJOB")) AND ("ACACCOUNTING"."P_CAACTIVITY"="PRCOMMITAC"."P_CAACTIVITY")) INNER JOIN "abecas_cs"."dbo"."IDMASTER" "IDMASTER_1" ON "PRCOMMITAC"."P_IDENTITY"="IDMASTER_1"."KEYSEQUENCE"
WHERE "ACACCOUNTING"."COMPANYID"='D2' AND "ACACCOUNTING"."FISCALYEAR"=2005
ORDER BY "ACACCOUNT"."ACCOUNT", "ACACCOUNTING"."FISCALYEAR", "ACACCOUNTING"."FISCALPERIOD", "ACBATCH"."KEYSEQUENCE