I have two SQL tables (table1 and table2), one of which contains dates for each day (column [dte_Date]) and the according level of an index (like the S&P 500) (column [flt_Close]), the other contains dates for each day (column [dte_ReportDate]) and the according prices for a product (column ([flt_Price]). I would like to make a VBA macro with two queries and then display in a Worksheet three columns :
DATE - LEVEL of the INDEX - Price of the PRODUCT
... - ... - ...
and so on. Unfortunately, the two tables don't always have the same dates so I can not write the first table and then fill the last column with the price of the product because the dates don't necessarily match.
So, how to make sure that I correctly fill the worksheet (if for one date there is only one value, then I want to display it and display "0" or "No value" for the other column) ?
Here is how the table look (table1) :
[dte_Date] ... [flt_Close]
2015-01-01 ... 2000
2015-01-02 ... 2010
2015-01-03 ... 2020
and (table2) :
[dte_ReportDate] ... [flt_Price]
2015-01-01 ... 10
2015-01-03 ... 11
and that would be the result I would like to have in my Excel worksheet:
DATE ... Close ... Price
01/01/15 2000 10
01/02/15 2010 No value (or 0)
01/03/15 2020 11