随笔分类 - mysql
摘要:注重效率
阅读全文
摘要:select DEPTNO as '部门编号',job as '工种',max(sal) as '不同部门里不同工种的最高工资' from emp group by DEPTNO,job;
阅读全文
摘要:select ename as '最高薪资人员的姓名' ,sal as '薪资' from emp where sal in(select max(sal) as '部门最高工资' from emp group by DEPTNO );
阅读全文
摘要:1.分组函数自动处理null,忽略null 2.分组函数不能出现在where条件语句中 3.分组函数可以组合在一起使用,可以嵌套 # 分组函数不能使用在where中 # 找出最低工资的员工薪资 select * from emp where sal=(select min(SAL) from emp
阅读全文
摘要:select ENAME as '姓名',SAL as '原始工资', (SAL*1.1) as '涨工资10%'from emp where job='MANAGER'; # 经理涨薪%10,销售涨薪%50 其余不变 需要使用 case when then when then else end s
阅读全文
摘要:select sal as '原始数据', round(sal) as '四舍五入后的数据' , round(sal,1) as '四舍五入1个小数点后的数据', round(sal,-1) as '四舍五入-1个小数点后的数据'from emp; # 生成100以内额随机整数 select rou
阅读全文
摘要:select sal as '原始数据', round(sal) as '四舍五入后的数据' ,round(sal,1) as '四舍五入1个小数点后的数据'from emp;
阅读全文
摘要:# 查询时 去掉前后的空格 select * from emp where ENAME=trim(' SMITH')
阅读全文
摘要:# 截取名字的第一个字母 注意开始下标是1 长度是1 格式(列名,开始下标,截取的长度) select substr(ENAME,1,1) from emp; # 获取员工姓名第一个字母是A的人员的信息 select * from emp where substr(ENAME,1,1)='A'; #
阅读全文
摘要:# 将查询到名字强转为小写select lower(ENAME) from EMP;
阅读全文
摘要:# 先用工资排序 ,如果工资相等,再用名字排序select * from emp order by sal desc,ENAME desc;
阅读全文
摘要:
阅读全文
摘要:# 模糊匹配 %包含的值%select * from emp where ENAME like '%S%'; # 找出名称以S开头的人的信息select * from emp where ENAME like 'S%'; # 找出名字以第二个字母是O的人的信息select * from emp wh
阅读全文
摘要:# 查询是800或5000的工资的人select * from emp where SAL in(800,5000); # 查询薪资在800到1000之间的人select * from emp where SAL between 800 and 5000;
阅读全文
摘要:
阅读全文
摘要:
阅读全文
浙公网安备 33010602011771号