0
は、私はそのような名前のurlTrafficのようなテーブルを持っていますで訪問されたこと。MySQLの複数のグループと複数のカウント
これは私のトップ250最も一般的に訪問したドメインを与える:のような結果と
select count(1) as domain_visits, domain
from urlTraffic
group by domain
order by domain_visits DESC
LIMIT 250;
:
+---------------+-----------------+
| domain_visits | domain |
+---------------+-----------------+
| 183002 | google.com |
| 150181 | facebook.com |
を、私はこれが私の場所のリスト与えることを知っている:
をselect distinct(location)
from urlTraffic
where domain = 'google.com';
しかし、結果セットを次のように設定する必要があります。
+---------------+-------------------------------------+
| domain_visits | domain | number_of_sites |
+---------------+-------------------------------------+
| 183002 | google.com | 15 |
| 150181 | facebook.com | 17 |
| 100002 | t.lkqd.net | 4 |
私はこのクエリを実行する方法があると知っていますが、それを把握することはできません。私は仕様を理解している場合、このような
Worked great!ありがとう、トン! – slthomason