我是 linq to sql 的初学者,我想知道内部连接中选择的语法是什么:
inner join ( select CCL_TMA_ID as SecurityIdMax ,
max(CCL_DATE) as DateMax
from dbo.usrCOURSCLOTURE
where CCL_DONNEE is not null
and CCL_DATE <= @d
group by CCL_TMA_ID
)
完整查询:
declare @d datetime
select @d = getdate()
select t0.CCL_TMA_ID as SecurityId ,
t0.CCL_DATE as Date ,
t0.CCL_DONNEE as Price ,
t1.CCL_DONNEE as CurrencyPrice
from dbo.usrCOURSCLOTURE as t0
inner join dbo.usrCOURSCLOTURE as t1 on t0.CCL_DEV_DONNEE = t1.CCL_TMA_ID
and t0.CCL_DATE = t1.CCL_DATE
and t1.CCL_DONNEE is not null
inner join ( select CCL_TMA_ID as SecurityIdMax ,
max(CCL_DATE) as DateMax
from dbo.usrCOURSCLOTURE
where CCL_DONNEE is not null
and CCL_DATE <= @d
group by CCL_TMA_ID
) cMax on t0.CCL_TMA_ID = SecurityIdMax
and t0.CCL_DATE <= DateMax
and t0.CCL_DATE >= DateMax-10
where t0.CCL_DATE > dateadd(year,-1,@d)