SQL不能排序的问题。
select distinct aa.CustomType,aa.LoanBlankDate,
(select BrachName from CAPS_BrachIns where ID =CAST(substring(aa.ContractNm ,2,2) as Int)) wd,
aa.CustomName,aa.ContractNm,aa.PeriodInterst,
isnull(c.receivableAmount,0),isnull(aa.PeriodInterst,0)-isnull(c.receivableAmount,0) receivebalance
from
(select b.CustomType,a.LoanBlankDate,a.CustomName,a.ContractNm,a.PeriodInterst,a.PeriodNm,a.IsAdvanceBlack
from InterestList a
left join OPSInf b on
a.ContractNm=b.LoanNm
where convert(varchar(10),LoanBlankDate,120) between '2013-08-26' and '2013-09-19'
) aa
left join
InterestReceive c on c.ContractNm=aa.ContractNm and c.PeriodNm=aa.PeriodNm and c.RepayType='PeriodInterst'
where aa.IsAdvanceBlack!='true' order by aa.CustomType,aa.LoanBlankDate,wd