我似乎遇到了查询语法错误,但似乎无法隔离它。我正在使用 MS Access,当我运行查询时,在 FROM 子句中出现语法错误。
我有两个表,它们是一对多的关系:
表 1 称为(客户),具有以下字段:
ID
FirstName
名为 (tblservice) 的表 2 包含以下字段:
serviceID
Timing
Total
customerID <-Foreign Key
第一个查询:
select c.id, c.firstname, avg(s.Total) / (select count(id) from customer) as LifetimeValue
from tblservice as s join customer as c on s.id = c.id
group by s.id
第二次查询(30天跨度):
select c.id, c.firstname, avg(s.Total) / (select count(id) from customer) as LifetimeValue
from tblservice as s join customer as c on s.id = c.id
where (s.Timing)>=DateAdd("d",-30,Date())
group by s.id