所以我有4个查询:
时间表,里程和费用查询都有一个字段(job_ID),它与tblJobs中的ID字段相关。我创建了一个报告,将信息(作为子报告)整合到主报告中,该报告查询作业查询。
对于每个作业,我想要一个A4报告页面,详细说明任何相关费用,从剩下的3个表格中分类,然后在页面底部对它们进行总计。这是为了协助我工作的公司生成发票。
一切正常,但报告为每份工作(所有2,300左右)生成一个A4页面,即使没有相关费用也没有。如何过滤报表以仅从三个表(tblTimesheet,tblExpenses和tblMileage)中恢复总计0.01英镑或更多的作业?
我猜这将通过主报告所查询的查询来完成。我认为可以通过在查询中创建一个额外的列来实现,该列为来自tblTimesheet,tblExpenses和tblMileage的job_ID的任何成本求和,然后仅过滤那些值为>£0.00的结果
我可以弄清楚如何过滤,但不知道如何在查询中创建额外的列来提取信息并对其进行求和。
任何指针?
以下查询的SQL代码:
职位查询:
SELECT tblJobs.ID, [tblClients]![client_name] AS Client, "R" & [ref] AS [Job No], tblJobs.title AS [Job Title]
FROM tblClients INNER JOIN tblJobs ON tblClients.[ID] = tblJobs.[client_ID];
时间表查询:
SELECT tblTimesheet.job_ID, tblTimesheet.datetime AS [Date], [firstName] & " " & [surname] AS Consultant, tblTimesheet.Activity, tblTimesheet.Hours, tblTimesheet.Rate, CCur([hours]*[rate]) AS Cost
FROM tblConsultants INNER JOIN tblTimesheet ON tblConsultants.[ID] = tblTimesheet.[consultant_ID];
费用查询:
SELECT tblExpenses.job_ID, tblExpenses.datetime AS [Date], [firstName] & " " & [surname] AS Consutlant, tblExpenses.Description, tblExpenses.cost
FROM (tblConsultants INNER JOIN tblJobs ON tblConsultants.[ID] = tblJobs.[main_SGP_consultant]) INNER JOIN tblExpenses ON tblConsultants.[ID] = tblExpenses.[consultant_ID];
里程查询:
SELECT tblMileage.job_ID, tblMileage.datetime, [firstName] & " " & [surname] AS Consultant, tblMileage.Description, tblMileage.Miles, CCur([miles]*0.5) AS Cost
FROM tblConsultants INNER JOIN tblMileage ON tblConsultants.[ID] = tblMileage.[consultant_ID];