select ReplenishDate,Amount
from vw_replenishmentData
where (select max(ReplenishDate) from vw_replenishmentData)
答案 0 :(得分:1)
您的where语句无效,请尝试以下操作:
select ReplenishDate,Amount
from
vw_replenishmentData
where ReplenishDate= (select max(ReplenishDate) maxDate from vw_replenishmentData)
答案 1 :(得分:1)
问题是您需要在哪里使用列名来过滤结果,例如.. where columnname = (select max(...
而不是使用subquery
使用Top 1 with Ties
。
select Top 1 with ties ReplenishDate,Amount
from vw_replenishmentData
order by ReplenishDate desc