Hello,
I am using Access 2010 with VBA code. I need to create a SQL statement that I can use for docmd.RunSQL (strSQL). I know I have done this in the past but haven't been able to figure it out.
I have Query1 and Query2. Then, I need to do a LEFT JOIN of the two results. Below is basically what I am trying to do. Does anyone know what the proper syntax would be?
SELECT a.id, a.cost, b.invoices FROM
(SELECT id, sum(cost) as cost FROM table1)a
LEFT JOIN
(SELECT id, count(invoices) as invoices FROM table2)b
ON a.id = b.id
Thanks for any help!!!
I am using Access 2010 with VBA code. I need to create a SQL statement that I can use for docmd.RunSQL (strSQL). I know I have done this in the past but haven't been able to figure it out.
I have Query1 and Query2. Then, I need to do a LEFT JOIN of the two results. Below is basically what I am trying to do. Does anyone know what the proper syntax would be?
SELECT a.id, a.cost, b.invoices FROM
(SELECT id, sum(cost) as cost FROM table1)a
LEFT JOIN
(SELECT id, count(invoices) as invoices FROM table2)b
ON a.id = b.id
Thanks for any help!!!