select AssetCode[资产编码],(select CategoryName from t_AssetClass where id=Assetid)[资产类别].Utime[变动日期] from t_FixedCode
想获得不同AssetCode的最早一条记录..试过这样,但是因为select 嵌套了一个select ,导致出错..select AssetCode[资产编码],(select CategoryName from t_AssetClass where id=Assetid)[资产类别].Utime[变动日期] ,count(distinct AssetCode) from t_FixedCode group by AssetCode
select AssetCode[资产编码],
(select CategoryName from t_AssetClass where id=Assetid) [资产类别],
Utime[变动日期]
from t_FixedCode
*
from
t_FixedCode a,t_AssetClass b
where
a.id=b.Assetid
and
not exists(select 1 from t_FixedCode where AssetCode=a.AssetCode and Utime>t.Utime)
这个是处理表重复记录的
然后再两表关联就行了