如何在MYSQL中使用COUNT里面的SELECT

Ath*_*eel 4 mysql sql view count

我有这个观点:

myVIEW :( id,%)

我想提出另一种观点,这将是这样的:

LASTVIEW :( lastID,lastPR,counter)

在"反击"中,在evrey系列中,我想知道如何赚钱比这条线的百分比更大.所以我试过了:

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;
Run Code Online (Sandbox Code Playgroud)

Tim*_*880 6

你几乎就在那里.试试这个:

SELECT id AS lastID, percent AS lastPR, (SELECT Count(id) 
FROM myVIEW bigger 
WHERE bigger.percent > myv.percent) AS counter
FROM myVIEW myv 
Run Code Online (Sandbox Code Playgroud)