V
Vacation's Over
I am having trouble with what should be a simple querry. I have a database
with info from many locations holding period information.
I am trying left outer join with dates table on left and data on right but I
can't get dates to show up unless data is present. I thought left join would
allow right to be empty?say including the periods through current year end in
table so printout will allow users to input forecasts.
"Generic" names used for readability:
Set cn = New ADODB.Connection
set rs as new ADODB.recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBName &
";"
myquery = ""
myquery = myquery + " SELECT Date.PeriodID, testdata.Data "
myquery = myquery + " FROM Date LEFT JOIN testdata ON Date.PeriodID =
testdata.PeriodID"
myquery = myquery + " WHERE Date. Year >= " & StartYear & " And Date.
Year <= " & EndYear & " AND testdata.LocName = " & Chr(34) & locname &
Chr(34) & " And testdata.COAName = " & Chr(34) & COAName & Chr(34)
myquery = myquery + " ORDER BY Date.PeriodID;"
Set rst = New ADODB.Recordset
With rst
.Open myquery, cn, adOpenKeyset, adLockReadOnly
aryHold1 = .GetRows()
end with
''cleanup
aryhold1 does not show what I expect......
For 2000 startyear and 2005 endyear - I expect 60 months in "left column"
and only data from querry data in the "right column" of the array say through
may 05. What I get is only matching dates to go with data as if inner join
was used?Array ends at May 05.
(I have confirmed that Date table has next few years of months in it)
Thanks
with info from many locations holding period information.
I am trying left outer join with dates table on left and data on right but I
can't get dates to show up unless data is present. I thought left join would
allow right to be empty?say including the periods through current year end in
table so printout will allow users to input forecasts.
"Generic" names used for readability:
Set cn = New ADODB.Connection
set rs as new ADODB.recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DBName &
";"
myquery = ""
myquery = myquery + " SELECT Date.PeriodID, testdata.Data "
myquery = myquery + " FROM Date LEFT JOIN testdata ON Date.PeriodID =
testdata.PeriodID"
myquery = myquery + " WHERE Date. Year >= " & StartYear & " And Date.
Year <= " & EndYear & " AND testdata.LocName = " & Chr(34) & locname &
Chr(34) & " And testdata.COAName = " & Chr(34) & COAName & Chr(34)
myquery = myquery + " ORDER BY Date.PeriodID;"
Set rst = New ADODB.Recordset
With rst
.Open myquery, cn, adOpenKeyset, adLockReadOnly
aryHold1 = .GetRows()
end with
''cleanup
aryhold1 does not show what I expect......
For 2000 startyear and 2005 endyear - I expect 60 months in "left column"
and only data from querry data in the "right column" of the array say through
may 05. What I get is only matching dates to go with data as if inner join
was used?Array ends at May 05.
(I have confirmed that Date table has next few years of months in it)
Thanks