日期:2014-05-17  浏览次数:21472 次

子查询返回的值多于一个,谁帮帮忙解决一下
SELECT TaxPayerID, TaxPayerName, iYear, BankName, TaxDeptName,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '1' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Jan1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '1' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Jan0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '2' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Feb1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '2' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Feb0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '3' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Mar1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '3' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Mar0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '4' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Apr1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '4' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Apr0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '5' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS May1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '5' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS May0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '6' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Jun1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '6' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Jun0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '7' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Jul1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '7' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Jul0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '8' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Aug1,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '8' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID) AS Aug0,
  (SELECT TaxMoney
  FROM CancelRep1
  WHERE iMonth = '9' AND iYear = a.iYear AND 
  CancelRep1.TaxPayerID = a.TaxPayerID AND CancelOrNot = 1) AS Sep1,
  (SELECT TaxMoney