`
wandejun1012
  • 浏览: 2738272 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

诡异SQL研究

    博客分类:
  • DB
 
阅读更多

SELECT ISNULL(ED.RegNo,'') as RegNo,ISNULL(ED.RefNo,'') as RefNo , ISNULL(ED.RoundNo,'') as RoundNo, ISNULL(S.RefDate_Sett,'') as RefDate_Sett , ISNULL(EH.PayAccount,'') as PayAccount , ISNULL(EH.PayAccountNmCN,'') as PayAccountNmCN , ISNULL(EH.PayAccountNmEN,'') as PayAccountNmEN , ISNULL(EH.ClCmtNo,'') as ClCmtNo, ISNULL(EH.ClCmtAccSbjtName,'') as ClCmtAccSbjtName, ISNULL(EH.ReceiptAccount,'') as ReceiptAccount , ISNULL(EH.ReceiptAccSbjt,'') as ReceiptAccSbjt , ISNULL(R.BillTypeNm,'') as BillTypeNm , ISNULL(R.BillTypeVal,'') as BillTypeVal , ISNULL(R.BAPerson,'') as BAPerson , ISNULL(R.AcpnBillNo,'') as AcpnBillNo, R.BillAmt as BillAmt, ISNULL(R.BilExecDate,'') as BilExecDate, ISNULL(R.BilMatDate,'') as BilMatDate, ISNULL(R.BillPayerIsDiffPlaceNm,'') as BillPayerIsDiffPlaceNm, ISNULL(EH.DiscBeginDate,'') as DiscBeginDate , ISNULL(EH.ExistRecourseVal,'') as ExistRecourseVal , ISNULL(ED.DiscMatDate,'') as DiscMatDate , ISNULL(S.BilSettDate,'') as BilSettDate , ISNULL(S.Account1,'') as Account1 , ISNULL(S.AcTtlSub1,'') as AcTtlSub1 , S.AccAmt1 as AccAmt1 , ISNULL(S.Account2,'') as Account2, ISNULL(S.AcTtlSub2,'') as AcTtlSub2, S.AccAmt2 as AccAmt2, ISNULL(S.Account3,'') as Account3 , ISNULL(S.AcTtlSub3,'') as AcTtlSub3 , S.AccAmt3 as AccAmt3 , ISNULL(S.IsExpiredVal,'') as IsExpiredVal , ISNULL(S.ExpiInterestRate,0) as ExpiInterestRate , ISNULL(S.ExpiPunishIntt,0) as ExpiPunishIntt , ISNULL(S.ExpiPunishAccount,'') as ExpiPunishAccount, ISNULL(S.ExpiPunishAcTtlSub,'') as ExpiPunishAcTtlSub, ISNULL(S.IsBuybackVal,'') as IsBuybackVal, ISNULL(S.RefusePayRsnDate,'') as RefusePayRsnDate, ISNULL(S.BillOriBackDate,'') as BillOriBackDate, ISNULL(S.BuyBackDate,'') as BuyBackDate, ISNULL(S.MakerId,'') as MakerId , ISNULL(S.MakerNm,'') as MakerNm , ISNULL(S.ChkerId,'') as ChkerId , ISNULL(S.ChkerNm,'') as ChkerNm , ISNULL(S.ApproverId,'') as ApproverId , ISNULL(S.ApproverNm,'') as ApproverNm , ISNULL(S.RejecterId,'') as RejecterId , ISNULL(S.RejecterNm,'') as RejecterNm , ISNULL(S.SettStasValue,'') as SettStasValue , ISNULL(S.SettStasName,'') as SettStasName , ISNULL(S.Remark1,'') as Remark1 , ISNULL(S.Remark2,'') as Remark2 , ISNULL(S.Remark3,'') as Remark3 , ISNULL(S.Remark4,'') as Remark4 , ISNULL(S.Remark5,'') as Remark5 , ISNULL(S.DelReason,'') as DelReason , ISNULL(S.UpdDate,'') as UpdDate , ISNULL(S.UpdateCount,0) as UpdateCount 
  FROM  B_DiscountExecH EH INNER JOIN B_DiscountExecD ED ON EH.DiscountNo=ED.DiscountNo 
  INNER JOIN B_DiscountReg  R on R.RegNo=ED.RegNo 
  INNER JOIN B_DiscountSett  S on S.RegNo=ED.RegNo 
  WHERE R.RegNo='B11091316014189' 
  AND EH.DiscountNo='000000000011' 
  AND ED.BookingBranch='8879' 
  AND ED.AmendCount=(
  SELECT isnull(MAX(AmendCount),0) as AmendCount FROM B_DiscountExecD  WHERE RegNo='B11091316014189'AND  BookingBranch='8879'AND  DiscountNo='000000000011'
  ) 
  AND S.UpdateCount=
  (
  SELECT isnull(MAX(UpdateCount),0) as UpdateCount  FROM B_DiscountSett  WHERE RegNo='B11091316014189'AND  BookingBranch='8879'
  )

 和下面的一段:

SELECT ISNULL(ED.RegNo,'') as RegNo,ISNULL(ED.RefNo,'') as RefNo , ISNULL(ED.RoundNo,'') as RoundNo, ISNULL(S.RefDate_Sett,'') as RefDate_Sett , ISNULL(EH.PayAccount,'') as PayAccount , ISNULL(EH.PayAccountNmCN,'') as PayAccountNmCN , ISNULL(EH.PayAccountNmEN,'') as PayAccountNmEN , ISNULL(EH.ClCmtNo,'') as ClCmtNo, ISNULL(EH.ClCmtAccSbjtName,'') as ClCmtAccSbjtName, ISNULL(EH.ReceiptAccount,'') as ReceiptAccount , ISNULL(EH.ReceiptAccSbjt,'') as ReceiptAccSbjt , ISNULL(R.BillTypeNm,'') as BillTypeNm , ISNULL(R.BillTypeVal,'') as BillTypeVal , ISNULL(R.BAPerson,'') as BAPerson , ISNULL(R.AcpnBillNo,'') as AcpnBillNo, R.BillAmt as BillAmt, ISNULL(R.BilExecDate,'') as BilExecDate, ISNULL(R.BilMatDate,'') as BilMatDate, ISNULL(R.BillPayerIsDiffPlaceNm,'') as BillPayerIsDiffPlaceNm, ISNULL(EH.DiscBeginDate,'') as DiscBeginDate , ISNULL(EH.ExistRecourseVal,'') as ExistRecourseVal , ISNULL(ED.DiscMatDate,'') as DiscMatDate , ISNULL(S.BilSettDate,'') as BilSettDate , ISNULL(S.Account1,'') as Account1 , ISNULL(S.AcTtlSub1,'') as AcTtlSub1 , S.AccAmt1 as AccAmt1 , ISNULL(S.Account2,'') as Account2, ISNULL(S.AcTtlSub2,'') as AcTtlSub2, S.AccAmt2 as AccAmt2, ISNULL(S.Account3,'') as Account3 , ISNULL(S.AcTtlSub3,'') as AcTtlSub3 , S.AccAmt3 as AccAmt3 , ISNULL(S.IsExpiredVal,'') as IsExpiredVal , ISNULL(S.ExpiInterestRate,0) as ExpiInterestRate , ISNULL(S.ExpiPunishIntt,0) as ExpiPunishIntt , ISNULL(S.ExpiPunishAccount,'') as ExpiPunishAccount, ISNULL(S.ExpiPunishAcTtlSub,'') as ExpiPunishAcTtlSub, ISNULL(S.IsBuybackVal,'') as IsBuybackVal, ISNULL(S.RefusePayRsnDate,'') as RefusePayRsnDate, ISNULL(S.BillOriBackDate,'') as BillOriBackDate, ISNULL(S.BuyBackDate,'') as BuyBackDate, ISNULL(S.MakerId,'') as MakerId , ISNULL(S.MakerNm,'') as MakerNm , ISNULL(S.ChkerId,'') as ChkerId , ISNULL(S.ChkerNm,'') as ChkerNm , ISNULL(S.ApproverId,'') as ApproverId , ISNULL(S.ApproverNm,'') as ApproverNm , ISNULL(S.RejecterId,'') as RejecterId , ISNULL(S.RejecterNm,'') as RejecterNm , ISNULL(S.SettStasValue,'') as SettStasValue , ISNULL(S.SettStasName,'') as SettStasName , ISNULL(S.Remark1,'') as Remark1 , ISNULL(S.Remark2,'') as Remark2 , ISNULL(S.Remark3,'') as Remark3 , ISNULL(S.Remark4,'') as Remark4 , ISNULL(S.Remark5,'') as Remark5 , ISNULL(S.DelReason,'') as DelReason , ISNULL(S.UpdDate,'') as UpdDate , ISNULL(S.UpdateCount,0) as UpdateCount 
  FROM  B_DiscountExecH EH INNER JOIN B_DiscountExecD ED ON EH.DiscountNo=ED.DiscountNo 
  INNER JOIN B_DiscountReg  R on R.RegNo=ED.RegNo 
  INNER JOIN B_DiscountSett  S on S.RegNo=ED.RegNo 
  WHERE R.RegNo='B11091316014189' 
  AND EH.DiscountNo='000000000011' 
  AND ED.BookingBranch='8879' 
  AND ED.AmendCount=(
  SELECT isnull(MAX(AmendCount),0) as AmendCount FROM B_DiscountExecD  WHERE RegNo='B11091316014189'AND  BookingBranch='8879'AND  DiscountNo='000000000011'
  ) 
  AND S.UpdateCount=
  (
  SELECT isnull(MAX(UpdateCount),0) as UpdateCount  FROM B_DiscountSett  WHERE ED.RegNo='B11091316014189'AND  ED.BookingBranch='8879'
  )
 看上去意思差不多,到底有何区别?出来的结果有时也不一样。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics