SQL分组统计
经典问题
统计每个组下TOP N的问题,例如统计每个学科前三名
数据表sql(GreenPlum):
create table tb_score(name varchar(20),subject varchar(20),score int)
distributed by (subject);
--数据插入表
insert into tb_score(name,subject,score) values
('john','math',80),
('john','english',78),
('john','history',90),
('judy','math',69),
('judy','history',92),
('judy','english',77