发疯!!!!
在 Access 上工作,在 MySQL 上不想要。我在这里的帖子上采取了窍门。
这里是查询:
SELECT A.B_ID,
B.CNT_B,
B.MAX_PRICE,
B.SUM_AB,
B.SUM_C_AB,
B.UNIQUE_B,
B.Costi,
B.COUNTDOWN,
A.AUCT_ID
FROM MONITOR AS A
INNER JOIN
(SELECT B_ID,
COUNT(B_ID) AS CNT_B,
MAX(PREZZO_ATTUALE) AS MAX_PRICE,
SUM(TOT_PUNT_AB) AS SUM_AB,
SUM(TOT_CAMBI_AB) AS SUM_C_AB,
(CNT_B-SUM_AB) AS UNIQUE_B,
(0.035*3*CNT_B+MAX_PRICE) AS COSTI,
45-SUM(CONT_PROVV_AB) AS COUNTDOWN
FROM MONITOR
WHERE AUCT_ID = '123456789'
GROUP BY B_ID) AS B
ON A.B_ID= B.B_ID
WHERE A.AUCT_ID = '123456789'
ORDER BY B.MAX_PRICE DESC,
B.CNT_B DESC
节目
错误:[MySQL][ODBC 3.51 驱动程序][mysqld-5.5.33-31.1-log]“字段列表”中的未知列“CNT_B”
如果我离开 CNT_B,它会告诉我 MAX_PRICE 等等。
我确定。这是一个 INNER JOIN 诅咒!
这里是错误的小提琴
解决方案
我不能在同一个子查询中使用 ALIAS 值。
所以新的 VALID 查询是:
SELECT A.B_ID,
B.CNT_B,
B.MAX_PRICE,
B.SUM_AB,
B.SUM_C_AB,
B.UNIQUE_B,
B.Costi,
B.COUNTDOWN,
A.AUCT_ID
FROM MONITOR AS A
INNER JOIN
(SELECT B_ID,
COUNT(B_ID) AS CNT_B,
MAX(PREZZO_ATTUALE) AS MAX_PRICE,
SUM(TOT_PUNT_AB) AS SUM_AB,
SUM(TOT_CAMBI_AB) AS SUM_C_AB,
(COUNT(B_ID)-SUM(TOT_PUNT_AB)) AS UNIQUE_B,
(0.035*3*COUNT(B_ID)+MAX(PREZZO_ATTUALE)) AS COSTI,
45-SUM(CONT_PROVV_AB) AS COUNTDOWN
FROM MONITOR
WHERE AUCT_ID = '123456789'
GROUP BY B_ID) AS B
ON A.B_ID= B.B_ID
WHERE A.AUCT_ID = '123456789'
ORDER BY B.MAX_PRICE DESC,
B.CNT_B DESC
谢谢
奥斯卡