UD - Tim | UD Employee | Member # 151 | posted November 06, 2002 20:38 ---------- We've encountered a problem with the code that replicates data from the primary database to the secondary database which supports the Member Stats. The Member Stats will be off-line while we investigate the problem and work on repairing it. We will post updates here as information becomes available. Thank you for your patience, ----------
参考SQLでつ。 SELECT (SELECT count(*) FROM 10xx AS a2 WHERE a2.d_Results>a1.d_Results)+1, a1.* FROM 10xx AS a1 ORDER BY a1.d_Results DESC, a1.d_Points DESC, a1.d_Time DESC LIMIT 0,500;
>SELECT (SELECT count(*) FROM 10xx AS a2 WHERE a2.d_Results>a1.d_Results)+1, a1.* >FROM 10xx AS a1 >ORDER BY a1.d_Results DESC, a1.d_Points DESC, a1.d_Time DESC LIMIT 0,500;
とりあえずパート2でつ。 SELECT Sum(IIf(a1.d_Results<a2.d_Results,1,0))+1 AS rank, a1.name, Max(a1.d_Results) FROM 10xx AS a1, 10xx AS a2 WHERE a1.Name<>a2.name GROUP BY a1.Name ORDER BY 3 desc;
MS-ACCESSで速攻で作って確認しただけです。スミマセン。 Sum(IIf(a1.d_Results<a2.d_Results,1,0))+1 AS rank の部分をMySQL用に書き換えてください。 本を見て書いただけなので式(Rankの部分)についての質問はご勘弁を。(よく理解していない) 普通のSQLではCASEとかを使うらしいでつ。 どう見ても処理速度が落ちるという諸刃の剣(MySQLなのにもったいない・゚・(ノД`)・゚・。) 素人(おいら)にはお勧めできない(爆)