日期:2014-05-17 浏览次数:20425 次
SELECT * FROM ( SELECT * FROM ( SELECT DISTINCT b.CustomNm , b.CIFNm , b.ApproveNm , b.loannm , b.LoanAmount , a.LoanBalance , b.LoanPerid , b.LoanStratDate , b.LoanEndDate , b.ComyLoanPurpose FROM InterestReceive a RIGHT JOIN OPSInf b ON a.ContractNm = b.LoanNm ) aa JOIN ---连接客户类型 ( SELECT DISTINCT * FROM ( SELECT a.LoanAccount , a.LoanNm , CASE b.LoanType WHEN '个人客户' THEN b.PerType WHEN '企业客户' THEN b.ComyCustomType ELSE '' END tp FROM OPSInf a LEFT JOIN LoanInf b ON a.CIFNm = b.CIFNm ) cc ) dd ON aa.LoanNm = dd.LoanNm ) bc
------解决方案--------------------
--MSSQL的括号只能用来括住数据集 而不能用来括住一个表 --例如 select * from (ta )a --报错 select * from (select * from ta)a --正确