有关数据库的一些基本知识
2015-08-01 19:20
429 查看
新建数据库表
create table employee( eid int(15) primary key auto_increment, ename varchar(20) not null, salary float(9,2) not null, deptid int(15) not null );
1、用两种方式根据部门号从高到低,工资从低到高列出每个员工的信息
select * from employee order by deptid desc,salary;
2、列出各个部门中工资高于本部门的平均工资的员工数和部门号,并按部门号排序
首先,下面这条语句是查询各个部门的平均工资select avg(salary) from employee group by deptid;
order by 与 group by 的区别:
order by 是排序;group by 是分组。 具体区别,再写个例子,一看便知:select * from employee group by deptid desc,salary;
select * from employee group by deptid desc;
#
相关文章推荐
- mongodb初识
- 数据库优化-基准测试(五)
- mysql 5.6.24 在cmd操作启动服务、停止服务操作
- SQL 2014 SP1 附加数据库时“create file遇到操作系统错误5拒绝访问”
- 使用innotop监测mysql
- Redis 发布与订阅
- windows server2008下apache+php+mysql+memcache安装与配置
- Oracle数据库软件标准版的一个限制:只能用一个rman channel
- Jedis - Redis事务
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- 【翻译自mos文章】recover.bsq文件在数据库软件安装光盘的哪个位置?
- Oracle常见函数的部分解释与示例
- [转]oracle 12c 中的分页子句
- mysql添加索引的方法,及max()函数的优化
- Redis 事务
- Redis Sentinel初体验
- 数据库优化 in 软件生命周期的不同阶段
- ORACLE 中split功能 & 包
- 小贝_redis web管理界面工具安装
- 小贝_redis安装与部署