I have the following query. I want to add another join to it, but can't seem to get the syntax correct. Can anyone help?The syntax is Microsoft Access as I am developing an Access report.SELECT ICTQ.STOCKGROUP AS AStockGroup, ICTQ.COSTTOTALS AS ACostTotals, SGUQ.VARIANCE AS AVariance, ICTQ.STOCKGROUP AS BSTOCKGROUP, SGAQ.VARIANCE AS BVARIANCEFROM Inventory_Cost_Totals_Query AS ICTQ LEFT OUTER JOIN (SELECT DISTINCT VARIANCE, STOCKGROUPFROM VARIANCE_BY_STOCK_GROUP_QUERY WHERE TYPEOFRECORD = "UPDATED RECORD") AS SGUQON ICTQ.STOCKGROUP = SGUQ.STOCKGROUP
This first query works fine and I get the expected results, the field in Italics is only for this second Join. This second join is the Join I would like to add, thus supporting the field in Italics. LEFT OUTER JOIN (SELECT DISTINCT VARIANCE, STOCKGROUPFROM VARIANCE_BY_STOCK_GROUP_QUERY WHERE TYPEOFRECORD <> "UPDATED_RECORDS") AS SGAQON ICTQ.STOCKGROUP = SGAQ.STOCKGROUP
Let me elaborate for further clarification. I have two tables, but three queries that I run. The first query provides me all of our StockGroups with their total dollar value. In another table, I store records when we update the inventory. There are only three fields: TYPEOFRECORD, VARIANCE, and STOCKGROUP. However, I have two queries to run against this table. One gets all records where the TYPEOFRECORD = "UPDATE RECORD". My second query gets any other records not found in the first query. I want to join these three queries to produce a report. The report looks like the following.STOCKGROUP STOCKTOTALS VARIANCE STOCKGROUP VARIANCEA1 1,200,000 175.00 A1 500.00A2 350,000 790.00 A2 0.00A3 90,000 0.00 A3 800.00
The only difference between the left side of the report and the right side is that the left side is for UPDATED records and the right side is for any other type of record.Hope this helps.