我有以下查詢,工作正常:SQL查詢永遠掛(8,0)字段
SELECT TMP_CLPUD.dbo.FormatS(RIGHT(SV1.VASLOC, 7), 9, 0) AS C_ACCOUNT,
TMP_CLPUD.dbo.FormatS(Cust.C_CUSTOMER, 7, 0) AS C_CUSTOMER,
CA.OID,
CN2.NBCUNQ AS CUNQ,
CN2.NBSUNQ AS SUNQ,
'AC' AS C_STATUS,
TMP_CLPUD.dbo.mmsDATE(CN2.NBCNTE) AS IN_DATE,
TMP_CLPUD.dbo.mmsDATE(CN2.NBDSTE) AS OUT_DATE,
0 AS ARCHIVE
FROM BILLING.SVP00100 AS SV1 INNER JOIN BILLING.CNP00200 AS CN2 ON SV1.VASUNQ = CN2.NBSUNQ
INNER JOIN BILLING.CMP00100 AS CM1 ON CN2.NBCUNQ = CM1.KACUST
INNER JOIN BILLING.CustomerAccounts AS CA ON CM1.KACUST = CA.CustomerNbr
INNER JOIN TMP_CLPUD.dbo.tblCustomers As Cust ON CA.OID = Cust.OID
INNER JOIN BILLING.Customers AS C ON CA.OID = C.OID
INNER JOIN BILLING.CNP00100 AS CN1 ON CN2.NBCUNQ = CN1.NACUNQ AND CN2.NBSUNQ = CN1.NASUNQ
ORDER BY C_ACCOUNT, C_CUSTOMER
但是,如果我嘗試CN1和CN2之間多了一個場環節,查詢將無限期掛起。該字段在兩個表中都是十進制(8,0)類型,不允許爲空值。這裏是到位的第三鏈接查詢:
SELECT TMP_CLPUD.dbo.FormatS(RIGHT(SV1.VASLOC, 7), 9, 0) AS C_ACCOUNT,
TMP_CLPUD.dbo.FormatS(Cust.C_CUSTOMER, 7, 0) AS C_CUSTOMER,
CA.OID,
CN2.NBCUNQ AS CUNQ,
CN2.NBSUNQ AS SUNQ,
'AC' AS C_STATUS,
TMP_CLPUD.dbo.mmsDATE(CN2.NBCNTE) AS IN_DATE,
TMP_CLPUD.dbo.mmsDATE(CN2.NBDSTE) AS OUT_DATE,
0 AS ARCHIVE
FROM BILLING.SVP00100 AS SV1 INNER JOIN BILLING.CNP00200 AS CN2 ON SV1.VASUNQ = CN2.NBSUNQ
INNER JOIN BILLING.CMP00100 AS CM1 ON CN2.NBCUNQ = CM1.KACUST
INNER JOIN BILLING.CustomerAccounts AS CA ON CM1.KACUST = CA.CustomerNbr
INNER JOIN TMP_CLPUD.dbo.tblCustomers As Cust ON CA.OID = Cust.OID
INNER JOIN BILLING.Customers AS C ON CA.OID = C.OID
INNER JOIN BILLING.CNP00100 AS CN1 ON CN2.NBCUNQ = CN1.NACUNQ AND CN2.NBSUNQ = CN1.NASUNQ AND CN2.NBCNTE = CN1.NACNTE
ORDER BY C_ACCOUNT, C_CUSTOMER
我已經重寫這個事情很多不同的方式,我能想到的,但每一次我嘗試它只是掛起永遠是第三場聯繫起來。有什麼建議麼?
那麼今天我們學習如何使用浮點類型(無論如何精確)作爲連接鍵? – 2010-07-06 14:21:20