转换如何选择查询

时间:2018-07-12 12:58:45

标签: sql sql-server access

我需要将此选择从sql server转换为Access

select ep.SWProduct_ID, ep.NormalizedName, e.Product, e.CreatedDate, MAX(m3.MappedDate)
from V_EOLProducts_ToMap ep 
inner join V_eol e on ep.Product = e.Product
inner join T_ProductEOL_Mapping m3 on m3.SwProduct_ID=e.SwProduct_ID 
where e.CreatedDate >'2018-07-05' 
and not exists (select * from T_ProductEOL_Mapping m where m.eol_id=e.eol_id)
and exists (select * from T_ProductEOL_Mapping m2 where m2.SwProduct_ID=e.SwProduct_ID)
AND e.CreatedDate > m3.MappedDate
group by ep.SWProduct_ID, ep.NormalizedName, e.Product, e.CreatedDate
order by SwProduct_ID 

我已经尝试过下面的查询,并且我还需要将值#01/07/2018#更改为变量

select ep.SWProduct_ID, ep.NormalizedName, e.Product, e.CreatedDate, MAX(m3.MappedDate)

from (dbo_V_EOLProducts_ToMap ep 
inner join dbo_V_eol e on ep.Product = e.Product)
inner join dbo_T_ProductEOL_Mapping m3 on m3.SwProduct_ID=e.SwProduct_ID 

where e.CreatedDate >#01/07/2018#
and not exists (select * from dbo_T_ProductEOL_Mapping m where m.eol_id=e.eol_id)
and exists (select * from dbo_T_ProductEOL_Mapping m2 where m2.SwProduct_ID=e.SwProduct_ID)
AND e.CreatedDate > m3.MappedDate

group by ep.SWProduct_ID, ep.NormalizedName, e.Product, e.CreatedDate

order by ep.SwProduct_ID  

编辑
从评论看来,他正在得到这个错误

enter image description here

1 个答案:

答案 0 :(得分:2)

access的联接样式很奇怪,您需要使用很多括号。
如果我没记错的话,这应该使您的加入对访问有效

from ((dbo_V_EOLProducts_ToMap ep 
  inner join dbo_V_eol e on ep.Product = e.Product)
  inner join dbo_T_ProductEOL_Mapping m3 on m3.SwProduct_ID = e.SwProduct_ID)
相关问题