先在Student表内插入5行数据。复习表插入操作。
#插入表Students数据 insert into public."Students"("StudentID","StudentName","StudentBirthday","StudentAddress","StudentSalary") values (1,'甄宝玉','1773-11-19','吉林省',1),(2,'贾宝玉','1770-07-01','辽宁省铁岭市',2),(3,'付子鱼','1988-03-26','南京市鼓楼区',12),(4,'窦 碧','1994-10-16','苏州市相城区',70),(5,'贾 明','1999-12-14','无锡市惠山区',50);
根据StudentSalary升序排列和降序排列。
#升序排列 select * from public."Students" order by "StudentSalary" asc; #降序排列 select * from public."Students" order by "StudentSalary" desc;
也可以多条件排序,下面演示根据StudentSalary和StudentName升序排序。
select * from public."Students" order by "StudentSalary","StudentName" asc;
GROUP BY子句通过多个记录收集数据,并将结果分组到一个或多个列。 也用于减少输出数据冗余。
#分组数据 select "StudentName",sum("StudentSalary") from "Students" group by "StudentName";