日期:2014-05-18  浏览次数:20432 次

取出日期这个字段的最大日期的前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