读书人

取出日期这个字段的最大日期的前10条记

发布时间: 2012-01-26 19:40:46 作者: rapoo

取出日期这个字段的最大日期的前10条记录
SELECT financial.effDate,financial.appDate,price.fundName,
price.bidPrice, price.offerPrice, financial.unitNum ,financial.accUnitNum * price.offerPrice AS InvestPrice
FROM financial INNER JOIN price ON financial.fundId = price.fundId
WHERE (financial.contractNo = 'BB00001001 ') and (price.transCode= '00 ' )

这是现在的sql
我要取出 financial.effDate 这个字段前10条 日期最大的记录

[解决办法]
select top 10 financial.effDate from
(SELECT financial.effDate,financial.appDate,price.fundName,
price.bidPrice, price.offerPrice, financial.unitNum ,financial.accUnitNum * price.offerPrice AS InvestPrice
FROM financial INNER JOIN price ON financial.fundId = price.fundId
WHERE (financial.contractNo = 'BB00001001 ') and (price.transCode= '00 ' )) t
order by financial.effDate desc

读书人网 >SQL Server

热点推荐