Yes, I am trying to make it much too complicated...
But I always find issues... ( I need to be hired as a tester for OrientDb)....
SELECT y,x,COUNT(*) as cnt FROM L0 WHERE COUNT(*) > 1 GROUP BY y,x << RETURNS EVERYTHING, cnt = 1 is all down my list
SELECT y,x,COUNT(*) as cnt FROM L0 GROUP BY y,x ORDER BY cnt DESC << These are the ones I need to focus on (this query works)
SELECT FROM (SELECT y,x,COUNT(*) as cnt FROM L0 GROUP BY y,x) WHERE cnt > 1 << Works.
SELECT FROM (SELECT y,x,@rid,COUNT(*) as cnt FROM L0 GROUP BY y,x) WHERE cnt > 1 LIMIT 1000 << This seems to get the last @rid like you suggested
SELECT FROM (SELECT y,x,MIN(@rid),COUNT(*) as cnt FROM L0 GROUP BY y,x) WHERE cnt > 1 LIMIT 1000 << This also seems to work, returning the first one.
^^^ I could use this to DELETE everything not with this first id but having the same y,x but I can't get that query to work.
x SELECT $x,$y FROM (SELECT COUNT(*) as cnt FROM LET $y=y,$x=x,$r=MIN(@rid) L0 GROUP BY y,x) WHERE cnt > 1 LIMIT 1000
I don't know how to write this. But I'd like to run DELETE VERTEX L0 WHERE x=$x and y=$y and @rid <> r
But I can run the first query you suggested, get the results and then write a Java program to run queries for the 500k things that need to be cleaned.
The Java program could execute statements like... "DELETE VERTEX L0 WHERE y = 49 and x = -123 and @rid <> #12:0"