order by rand() の group by

group by の結果を order by rand() でランダムに出力しようとしてもできない。
そんなときは order by rand() した結果を from に当てはめて出力する。

構文は違うけど、ニュアンス的には以下になる。

select url, name, mail from order by url;

上記を from に突っ込んで group by する。

select url, name, mail from (select url, name, mail from order by url) group by url;

これで url の重複を削除したname, mail が1件だけ出力される。