クライアントが閲覧した製品を含むテーブルがあります。次のようになります。
| id | visitor_id | product |
| 1 | 51a474f | 5 |
| 2 | 51a474f | 3 |
| 3 | 51a474f | 3 |
| 4 | 207ed9e | 3 |
| 4 | 207ed9e | 5 |
| 5 | 47d98ee | 4 |
| 6 | 47d98ee | 3 |
| 7 | 47d98ee | 2 |
そして、誰かが例えば製品番号を訪問した場合。5、同じ製品を訪問したすべての訪問者を取得し、すべての製品 (ID が 5 以外) をグループ化し、訪問数でカウントしたいと考えています。
複数のクエリでこれを実行できることはわかっていますが、そのソリューションよりも単一のクエリの方が優れていると思います。