我有12GB的表数据。
我的表格如下:
userid name score
1 abc 1
1 pqr 1
2 mno 1
2 pqr 1
.
.
.
750000 mno 1
这是我的疑问:
select a.userid as user1,b.userid as user2, sum(a.score*b.score) as score,count(distinct a.name) as distinct_name from table a join table b on(a.name=b.name) limit 10;
它运行了几个小时但没有返回结果。我该如何解决这个问题?
答案 0 :(得分:0)
试试这个,
select a.userid as user1,b.userid as user2, sum(a.score*b.score) as score,count(distinct a.name) as distinct_name
from table a join table b on(a.name=b.name)
group by a.userid , b.userid
limit 10;
将您的表名替换为表格;