我有一个这种格式的SQL表:
Screenname|realname|followers|tweet
bob |jim |5 |hi
bob |jim |20 |hello
tom |joe |15 |JOETHECAT
tim |joe |16 |TEST
我需要编写一个查询,显示每个唯一的屏幕名称及其实名和跟随者的总数。
Screename realname followers
bob jim 25
tom joe 15
tim joe 16
答案 0 :(得分:2)
按Screename,realname和SUM关注者使用GROUP BY。
select Screename, realname, sum(followers) as followers
from your_table
group by Screename, realname
答案 1 :(得分:0)
尝试一下:
group
答案 2 :(得分:0)
使用group by
很简单select Screename, realname, sum(followers) as followers
from your_table
group by Screename, realname