赞
踩
首先创建users表
- create table users(
- id serial primary key,
- player varchar(255) not null,
- score real,
- team varchar(255)
- )
插入记录并select
- insert into users(player,score,team) values
- ('库里',28.3,'勇士'),
- ('哈登',30.2,'火箭'),
- ('阿杜',25.6,'勇士'),
- ('阿詹',27.8,'骑士'),
- ('神龟',31.3,'雷霆'),
- ('白边',19.8,'热火');
查询所有记录:select * from users
这就是users中所有的记录
select * from users order by score;//默认为升序
select * from users order by score asc;//升序
select * from users order by score desc;//降序
select * from users order by team;//拼音首字母排序,如果首字母相同,则排拼音第二个字母,以此类推
select * from users order by team,score;//先对team升序排序,再在排序后的表中对score升序排序。如下
select * from users order by team,score desc;//先对team升序排序,再在排序后的表中对score降序排序。如下
select * from users order by score desc limit 4
select * from users order by score desc limit 4 offset 1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。