我无法通过开始日期和结束日期字段来获取此SQL语句来过滤表格。所有字段都在同一个表格中,我不确定我是否已经错误地制定了一些内容......我显然是对SQL的新手,感谢您提供的任何帮助。
ExecuteSQL (
"
SELECT sum (Billing_Tab_Hours_Total_1
+ Billing_Tab_Hours_Total_2
+ Billing_Tab_Hours_Total_3
+ Billing_Tab_Hours_Total_4
+ Billing_Tab_Hours_Total_5
+ Billing_Tab_Hours_Total_6
+ Billing_Tab_Hours_Total_7
+ Billing_Tab_Hours_Total_8
+ Billing_Tab_Hours_Total_9
+ Billing_Tab_Hours_Total_10)
FROM TABLE
WHERE Billing_Tab_Name_1 = 'Employee Name'
OR Billing_Tab_Name_2 = ‘Employee Name’
OR Billing_Tab_Name_3 = 'Employee Name'
OR Billing_Tab_Name_4 = 'Employee Name'
OR Billing_Tab_Name_5 = 'Employee Name'
OR Billing_Tab_Name_6 = 'Employee Name'
OR Billing_Tab_Name_7 = 'Employee Name'
OR Billing_Tab_Name_8 = 'Employee Name'
OR Billing_Tab_Name_9 = 'Employee Name'
OR Billing_Tab_Name_10 = 'Employee Name'
AND Billing_Tab_Date_1 BETWEEN Report_Starting_Date and Report_Ending_Date
OR Billing_Tab_Date_2 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_3 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_4 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_5 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_6 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_7 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_8 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_9 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_10 BETWEEN Report_Starting_Date AND Report_Ending_Date
"
; "" ; "" )
答案 0 :(得分:0)
试试这个:
如果您不关心Billing_Tab_name与Billing_Tab_hours的匹配,那么您可以使用:
ExecuteSQL ("
SELECT sum (Billing_Tab_Hours_Total_1
+ Billing_Tab_Hours_Total_2
+ Billing_Tab_Hours_Total_3
+ Billing_Tab_Hours_Total_4
+ Billing_Tab_Hours_Total_5
+ Billing_Tab_Hours_Total_6
+ Billing_Tab_Hours_Total_7
+ Billing_Tab_Hours_Total_8
+ Billing_Tab_Hours_Total_9
+ Billing_Tab_Hours_Total_10)
FROM TABLE
WHERE (Billing_Tab_Name_1 = 'Employee Name'
OR Billing_Tab_Name_2 = ‘Employee Name’
OR Billing_Tab_Name_3 = 'Employee Name'
OR Billing_Tab_Name_4 = 'Employee Name'
OR Billing_Tab_Name_5 = 'Employee Name'
OR Billing_Tab_Name_6 = 'Employee Name'
OR Billing_Tab_Name_7 = 'Employee Name'
OR Billing_Tab_Name_8 = 'Employee Name'
OR Billing_Tab_Name_9 = 'Employee Name'
OR Billing_Tab_Name_10 = 'Employee Name')
AND (Billing_Tab_Date_1 BETWEEN Report_Starting_Date and Report_Ending_Date
OR Billing_Tab_Date_2 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_3 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_4 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_5 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_6 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_7 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_8 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_9 BETWEEN Report_Starting_Date AND Report_Ending_Date
OR Billing_Tab_Date_10 BETWEEN Report_Starting_Date AND Report_Ending_Date)
"; "" ; "" )
但如果他们必须匹配那么你需要这个:
ExecuteSQL ("
SELECT sum (Billing_Tab_Hours_Total_1
+ Billing_Tab_Hours_Total_2
+ Billing_Tab_Hours_Total_3
+ Billing_Tab_Hours_Total_4
+ Billing_Tab_Hours_Total_5
+ Billing_Tab_Hours_Total_6
+ Billing_Tab_Hours_Total_7
+ Billing_Tab_Hours_Total_8
+ Billing_Tab_Hours_Total_9
+ Billing_Tab_Hours_Total_10)
FROM TABLE
WHERE (Billing_Tab_Name_1 = 'Employee Name' AND Billing_Tab_Date_1 BETWEEN Report_Starting_Date and Report_Ending_Date)
OR (Billing_Tab_Name_2 = ‘Employee Name’ AND Billing_Tab_Date_2 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_3 = 'Employee Name' AND Billing_Tab_Date_3 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_4 = 'Employee Name' AND Billing_Tab_Date_4 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_5 = 'Employee Name' AND Billing_Tab_Date_5 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_6 = 'Employee Name' AND Billing_Tab_Date_6 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_7 = 'Employee Name' AND Billing_Tab_Date_7 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_8 = 'Employee Name' AND Billing_Tab_Date_8 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_9 = 'Employee Name' AND Billing_Tab_Date_9 BETWEEN Report_Starting_Date AND Report_Ending_Date)
OR (Billing_Tab_Name_10 = 'Employee Name' AND Billing_Tab_Date_10 BETWEEN Report_Starting_Date AND Report_Ending_Date)
"; "" ; "" )