組我下面的查詢:甲骨文空值問題與
SELECT EMAIL.MAILADDRESS, COUNT (DISTINCT CUSTOMER.CUSTOMER_ID) distinct_count
FROM ( SELECT CUSTOMER_ID,
TRUNC (MAX (UPDATE_DATE)) AS UPDATE_TARIHI,
TRUNC (MIN (INSERT_DATE)) AS DATA_ENTRY_DATE,
'YES' AS MAILADDRESS
FROM ELECTRONIC_ADDRESS
WHERE ADDRESS_TYPE = 'ELECTRONIC'
GROUP BY CUSTOMER_ID) EMAIL
RIGHT OUTER JOIN
CUSTOMER
ON (EMAIL.CUSTOMER_ID = CUSTOMER.CUSTOMER_ID)
GROUP BY EMAIL.MAILADDRESS
我加入電子郵件(子查詢-incoludes「E」 AS MAILADDRESS)和客戶表。 有些客戶不具有的emailadress所以我認爲結果應該是像belowe條款:
MAILADDRESS DISTINCT_COUNT
YES 158945
NULL 76345
但是當我運行此查詢時,只顯示第一行(其電子郵件地址是YES)
如果我將EMAIL.MAILADDRESS子句更改爲選定列中的nvl(EMAIL.MAILADDRESS,「否」)並逐個分組,查詢運行完美。 但我無法解決問題,因爲該查詢是從Business Objects Universe生成的,所以我無法更改該查詢。
我們寫這個部分:
SELECT CUSTOMER_ID,
TRUNC (MAX (UPDATE_DATE)) AS UPDATE_TARIHI,
TRUNC (MIN (INSERT_DATE)) AS DATA_ENTRY_DATE,
'YES' AS MAILADDRESS
FROM ELECTRONIC_ADDRESS
WHERE ADDRESS_TYPE = 'ELECTRONIC'
GROUP BY CUSTOMER_ID
,然後構建一個合適的加入這個部分和客戶表之間的關係。
我該如何解決問題?爲什麼Oracle不顯示空值?
如果你看一下在第一個查詢後,你會看到這個部分在「右外連接」的左側。 – Allan