我有一个SQL查询,我想在MS Access中使用,但我无法正确使用它。任何帮助都会受到赞赏。
yourservice.cloudapp.net
答案 0 :(得分:1)
如果您的查询目前有效,我建议:
select kp.Id, kp.KPI_id, kp.Quantity, kp.FinancialMonth,
kp.FinancialYear, kp.ImportTimestamp,
d.Dashboard_Id
from ((select tblKPIData.kpi_id,
max(tblKPIData.ImportTimestamp) as ImportTimestamp
from tblKPIData
group by tblKPIData.KPI_id
) as b inner join
tblKPIData as kp
on kp.KPI_id = b.KPI_id and kp.ImportTimestamp = b.ImportTimestamp
) right join
tblDashboadKPI as d
on d.KPI_Id = kp.KPI_id
where FinancialMonth = "nov" and FinancialYear = 2016 and
d.Dashboard_Id = 5
order by kp.Id, kp.KPI_id;
的变化:
JOIN
需要额外的括号答案 1 :(得分:1)
我想我有解决方案:
SELECT tblKPIData.Id
, tblKPIData.KPI_id
, tblKPIData.Quantity
, tblKPIData.FinancialMonth
, tblKPIData.FinancialYear
, tblKPIData.ImportTimestamp
, tblKPIData.Type
, tblDashboadKPI.Dashboard_Id
FROM tblDashboadKPI
INNER JOIN tblKPIData
ON tblDashboadKPI.KPI_Id = tblKPIData.KPI_id
WHERE (((tblKPIData.FinancialMonth)="nov")
AND ((tblKPIData.FinancialYear)=2016)
AND ((tblKPIData.ImportTimestamp)=(select max(d2.ImportTimestamp)
from tblKPIData as d2
where d2.KPI_Id = tblKPIData.KPI_Id))
AND ((tblDashboadKPI.Dashboard_Id)=5));
Thanx为你提供帮助!