我有三个 MS Access 表。它们Income_Statements
是Balance_Sheets
和Cash_Flow_Statements
。这些表都共享相同的主键。它是一个包含Ticker
,[Year]
和的三字段主键Period
。当然,我想在不复制主键字段的情况下组合所有这三个表。我也有一个需要满足的日期标准。我需要显示的记录等于或早于我从DateTimePicker
被调用的日期中选择的日期dtpDateSelection
。
这是我到目前为止所拥有的:
Dim year As String = dtpDateSelection.Value.Year
Dim quarter As String = ((dtpDateSelection.Value.Month - 1) \ 3) + 1
Dim cmd2 As OleDbCommand = New OleDbCommand("SELECT Ticker, [Year], Period, Income_Statements.Net_Income, Balance_Sheets.Total_Assets, Cash_Flow_Statements.Net_Cash_Flow_Operating FROM Income_Statements, Balance_Sheets, Cash_Flow_Statements WHERE Period < 5 AND Period <= #" & quarter & "# AND [Year] <= #" & year & "#", con)
Dim quarterlyReader As OleDbDataReader = cmd2.ExecuteReader()
Dim Quarterly As New DataTable
Quarterly.Load(quarterlyReader)
DataGridViewScreen.DataSource = Quarterly
quarterlyReader.Close()
我的WHERE
陈述有问题。我怎样才能使这项工作?