我的看法是:
我的 View :(id,百分比)
我想再做一个 View ,会是这样的:
LASTVIEW:(lastID、lastPR、计数器)
在“计数器”中,在每一行中,我都希望货币 id 的百分比大于该行的百分比。所以我尝试了:
CREATE VIEW LASTVIEW(lastID, lastPR, counter) AS
SELECT id AS lastID, percent AS lastPR
COUNT (SELECT id FROM myVIEW WHERE percent < lastPR) AS counter,
FROM myVIEW;
最佳答案
你快到了。试试这个:
SELECT id AS lastID, percent AS lastPR, (SELECT Count(id)
FROM myVIEW bigger
WHERE bigger.percent > myv.percent) AS counter
FROM myVIEW myv
关于mysql - 如何在 MYSQL 的 COUNT 中使用 SELECT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30245300/