2019独角兽企业重金招聘Python工程师标准>>>
第一步:创建表及数据:
create table uid(uid int, --uidcate varchar(20), --类别price double --金额
)
insert into uid values(123,'c1',21);
insert into uid values(123,'c2',23);
insert into uid values(123,'c3',14);
insert into uid values(123,'c4',25);
insert into uid values(123,'c8',10);
insert into uid values(124,'c1',28);
insert into uid values(124,'c15',25);
insert into uid values(124,'c2',12);
insert into uid values(124,'c31',40);
insert into uid values(124,'c7',15);
查询结果:
第二步:取uid的金额最多的前四名
1.获取所有记录
2.增加序列并过滤(增加序列需要排序):
4.完成并查询结果: