0
下面是我的sql語句,一切工作正常,只是我不知道如何從多個返回值中找到MAX。無論如何,這裏是我的代碼,我有問題的部分用[]標記。如何從多個返回值中找到MAX
SELECT
(product1.CNT+product2.CNT+product3.CNT)AS CNT,
(
IFNULL(product1.SUMAMT,0)+
IFNULL(product2.SUMAMT,0)+
IFNULL(product3.SUMAMT,0)
)AS AMTAMT,
[MAX(product1.MXDT,product2.MXDT,product3.MXDT)AS MAXDT]
FROM
(SELECT
SUM(LAMT)AS SUMAMT,
COUNT(LAMT)AS CNT,
IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY))AS MXDT
FROM product1 WHERE LSUBBY=1 AND RECST=1
)product1
CROSS JOIN
(SELECT
SUM(LAMT)AS SUMAMT,
COUNT(LAMT)AS CNT,
IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY))AS MXDT
FROM product2 WHERE LSUBBY=1 AND RECST=1
)product2
CROSS JOIN
(SELECT
SUM(LAMT)AS SUMAMT,
COUNT(LAMT)AS CNT,
IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY))AS MXDT
FROM product3 WHERE LSUBBY=1 AND RECST=1
)product3