Function dbquery(filepath)
Dim Selectquery, Innerquery As String
Selectquery = "SELECT Performance.ID As Code, Information.F1 As Fund, Performance.Date As MM_DD_YYYY, IIF([SystemInformation6.F4]='','No','Yes') As Leverage, "
Innerquery = "FROM `" & filepath & "`.`Performance` INNER JOIN (`" & filepath & "`.`Information` INNER JOIN `" & filepath & "`.`SystemInformation6` ON Information.ID = SystemInformation6.ID)" & Chr(10) & Chr(13) & "ON Performance.ID = Information.ID"
dbquery = Array( _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Event Driven' As Main_Strategy", Innerquery, "WHERE Information.C1 = -1", "Union", _
Selectquery & "[COLOR=red]IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged]) As Performance[/COLOR], 'AUM' As [PType], 'Event Driven' As Main_Strategy", Innerquery, "WHERE Information.C1 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Long/Short Equity' As Main_Strategy", Innerquery, "WHERE Information.C2 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Long/Short Equity' As Main_Strategy", Innerquery, "WHERE Information.C2 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Equity Market Neutral' As Main_Strategy", Innerquery, "WHERE Information.C3 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Equity Market Neutral' As Main_Strategy", Innerquery, "WHERE Information.C3 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Convertible Arbitrage' As Main_Strategy", Innerquery, "WHERE Information.C4 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Convertible Arbitrage' As Main_Strategy", Innerquery, "WHERE Information.C4 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Fixed Income Arbitrage' As Main_Strategy", Innerquery, "WHERE Information.C5 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Fixed Income Arbitrage' As Main_Strategy", Innerquery, "WHERE Information.C5 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Dedicated Short Bias' As Main_Strategy", Innerquery, "WHERE Information.C6 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Dedicated Short Bias' As Main_Strategy", Innerquery, "WHERE Information.C6 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Emerging Markets' As Main_Strategy", Innerquery, "WHERE Information.C7 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Emerging Markets' As Main_Strategy", Innerquery, "WHERE Information.C7 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Managed Futures' As Main_Strategy", Innerquery, "WHERE Information.C13 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Managed Futures' As Main_Strategy", Innerquery, "WHERE Information.C13 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Global Macro' As Main_Strategy", Innerquery, "WHERE Information.C14 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Global Macro' As Main_Strategy", Innerquery, "WHERE Information.C14 = -1", "Union", _
Selectquery & "Performance.Return As Performance, 'ROI' As [PType], 'Fund of Funds' As Main_Strategy", Innerquery, "WHERE Information.C15 = -1", "Union", _
Selectquery & "IIF([Performance.FundsManaged]='0','', [Performance.FundsManaged])As Performance, 'AUM' As [PType], 'Fund of Funds' As Main_Strategy", Innerquery, "WHERE Information.C15 = -1")
End Function