4
Stackoverflow,你好。 有以下問題。 假設具有返回查詢如下:SQL MAX函數奇怪的行爲
當我嘗試它 「選擇MAX(COL1),MAX(COL2)」,它返回我:
了when我嘗試「選擇MAX(COL2),MAX(COL1)」返回我:
你有這裏發生了什麼的任何想法?
,使該問題的查詢是
select max(col2),max(col1)
from (
SELECT
NVL(IS_IN_OPEN_BR, 0) AS col1,
NVL(IS_IN_OPEN_ISR, 0) AS col2
FROM
(
SELECT DISTINCT PRD_DEV_CODE AS DEV_CODE_ISR,
PRD_GRP_CODE AS GRP_CODE_ISR,
1 AS IS_IN_OPEN_ISR
FROM ATL_ADM.PRODUCT PRD
INNER JOIN ATL_ADM.SB_REQ SR
ON PRD.PRD_ID = SR.SBR_PRD_ID
INNER JOIN ATL_ADM.LIB_REPLENISH_REQ LSR
ON LSR.LSR_ID = SR.SBR_LSR_ID
WHERE LSR.LSR_STATUS <> 'CLOSED'
GROUP BY PRD_DEV_CODE,
PRD_GRP_CODE
) ISR
FULL OUTER JOIN
(
SELECT DISTINCT PRD.PRD_DEV_CODE DEV_CODE_SHIP,
PRD.PRD_GRP_CODE AS GRP_CODE_SHIP,
NVL(MAX (SHP.SHIP_SHIPDATE), MAX (SHP.SHIP_UPDDATET)) LAST_SHIP_DATE
FROM ATL_ADM.SB_REQ SR
JOIN ATL_ADM.SHIPMENT SHP
ON SR.SBR_ID = SHP.SHIP_SBR_ID
JOIN ATL_ADM.PRODUCT PRD
ON PRD.PRD_ID = SR.SBR_PRD_ID
WHERE SR.SBR_TYPE = 'FLA'
AND SHP.SHIP_STATUS IN ('SHIPPE', 'MANDEV')
GROUP BY PRD.PRD_DEV_CODE ,
PRD.PRD_GRP_CODE
) SHIPS ON DEV_CODE_ISR = DEV_CODE_SHIP
FULL OUTER JOIN
(
SELECT DISTINCT
PRODUCT.PRD_DEV_CODE DEV_CODE_BR,
PRODUCT.PRD_GRP_CODE GRP_CODE_BR,
1 IS_IN_OPEN_BR
FROM ATL_ADM.PRODUCT
JOIN ATL_ADM.SB_REQ
ON PRODUCT.PRD_ID = SB_REQ.SBR_PRD_ID
JOIN ATL_ADM.REQT_SET
ON REQT_SET.REQTS_ID = SB_REQ.SBR_RS_ID
JOIN ATL_ADM.BRIEF
ON BRIEF.BR_ID = REQT_SET.REQTS_BR_ID
WHERE BRIEF.BR_STATUS_CODE NOT IN ('CLOSED', 'CANCEL')
GROUP BY PRODUCT.PRD_GRP_CODE,
PRODUCT.PRD_DEV_CODE,
BRIEF.BR_STATUS_CODE
) BRS ON DEV_CODE_BR = DEV_CODE_SHIP)
向我們展示SQL查詢,我用它[沒問題](http://pastebin.com/zq2gFd2v) – zaratustra 2014-09-01 08:07:41
不止SQL查詢,請你提供一個完整的環境來演示這種行爲,包括表DDL ,插入語句和SQL查詢。在沒有人能夠重現的情況下,可能有人需要查看某些數據庫參數。 – Ben 2014-09-01 08:14:01
我測試過了,沒有這樣的結果 – sotondolphin 2014-09-01 08:22:36